Пример #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
Пример #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)
Пример #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
Пример #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
Пример #5
0
def test_create_with_segments():
    collection = SegmentCollection.from_segments([Segment("36CF")])
    assert [Segment("36CF")] == collection.segments
Пример #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')