Ejemplo n.º 1
0
def test_get_segments():
    collection = SegmentCollection.from_segments(
        [Segment("36CF", 1),
         Segment("CPD"),
         Segment("36CF", 2)])
    segments = list(collection.get_segments("36CF"))
    assert [Segment("36CF", 1), Segment("36CF", 2)] == segments
Ejemplo n.º 2
0
def test_get_segments_w_predicate():
    collection = SegmentCollection.from_segments([
        Segment("A", '1', 'a'),
        Segment("A", '2', 'b'),
        Segment("A", '1', 'c'),
    ])
    segments = collection.get_segments("A", lambda x: x[0] == '1')
    assert [
        Segment("A", '1', 'a'),
        Segment("A", '1', 'c'),
    ] == list(segments)
Ejemplo n.º 3
0
def test_str_serialize():
    collection = SegmentCollection.from_segments(
        [Segment("36CF", "1"), Segment("36CF", "2")])
    string = str(collection)
    assert "36CF+1'36CF+2'" == string
Ejemplo n.º 4
0
def test_get_segment():
    collection = SegmentCollection.from_segments(
        [Segment("36CF", 1), Segment("36CF", 2)])
    segment = collection.get_segment("36CF")
    assert Segment("36CF", 1) == segment
Ejemplo n.º 5
0
def test_create_with_segments():
    collection = SegmentCollection.from_segments([Segment("36CF")])
    assert [Segment("36CF")] == collection.segments
Ejemplo n.º 6
0
def test_get_segment_w_predicate():
    collection = SegmentCollection.from_segments(
        [Segment("36CF", '1'), Segment("36CF", '2')])
    segment = collection.get_segment("36CF", lambda x: x[0] == '2')
    assert segment == Segment("36CF", '2')