File size: 1,152 Bytes
71a7230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""Test amend_avec."""
from itertools import count, zip_longest
from radiobee.amend_avec import amend_avec


def test_amend_avec():
    """Test amend_avec."""
    assert not amend_avec([])
    assert amend_avec([], 3, 2) == [(0, 0), (1, 1), (2, "")]


def test_amend_avec1():
    """Test avec."""
    avec = [
        (0, 0),
        (1, 0),
        (3, 1),
        (4, 1),
        (9, 2),
        (10, 2),
        (13, 3),
        (14, 3),
        (15, 4),
        (16, 4),
        (22, 5),
        (23, 5),
        (27, 6),
        (28, 6),
    ]
    set0, set1 = zip(*amend_avec(avec))
    set0_ = list(set(set0))
    set1_ = list(set(set1))
    assert [*range(29)] == [elm for elm in sorted(set0_, key=set0.index) if elm != ""]
    assert [*range(7)] == [elm for elm in sorted(set1_, key=set1.index) if elm != ""]

    assert [*range(29)] == [elm for elm in dict(zip(set0, count())) if elm != ""]
    assert [*range(7)] == [elm for elm in dict(zip(set1, count())) if elm != ""]

    assert [*range(29)] == [elm for elm in dict(zip_longest(set0, [])) if elm != ""]
    assert [*range(7)] == [elm for elm in dict(zip_longest(set1, [])) if elm != ""]