def test_registry_multiplesegment_invert(values):
    r = Registry()

    for point in values:
        r.add(point)

    assert (~~r).acked == r.acked
Beispiel #2
0
def test_registry_add_only_accept_integers():
    from binlog.registry import Registry

    r = Registry()

    with pytest.raises(TypeError):
        r.add(None)
Beispiel #3
0
def test_registry_double_add():
    from binlog.registry import Registry

    r = Registry()

    assert r.add(0)
    assert not r.add(0)
Beispiel #4
0
def test_registry_is_iterator(points):
    from binlog.registry import Registry

    r = Registry()
    for p in points:
        r.add(p)

    assert list(r) == sorted(points)
Beispiel #5
0
def test_registry_add_consecutive_left_side(data):
    from binlog.registry import Registry

    r = Registry()

    r.add(data)
    r.add(data - 1)

    assert (data - 1, data) in r.acked
Beispiel #6
0
def test_registry_contains(data, point):
    from binlog.registry import Registry

    r = Registry()

    for i in data:
        r.add(i)

    assert (point in r) == (point in data)
Beispiel #7
0
def test_registry_is_always_sorted(data):
    from binlog.registry import Registry

    r = Registry()

    for i in data:
        r.add(i)

    assert list(r.acked) == sorted(r.acked)  # sorted always returns list
Beispiel #8
0
def test_registry_add_consecutive_left_and_right(data):
    from binlog.registry import Registry

    r = Registry()

    r.add(data - 1)
    r.add(data + 1)
    r.add(data)

    assert (data - 1, data + 1) in r.acked
Beispiel #9
0
def test_registry_add_non_consecutive(data):
    from binlog.registry import Registry

    r = Registry()

    r.add(0)
    assert (0, 0) in r.acked

    r.add(data)
    assert (data, data) in r.acked
Beispiel #10
0
def test_registry_add_randomized_range(data):
    from binlog.registry import Registry

    r = Registry()

    l = list(range(data, data + 101)) * random.randint(1, 3)
    random.shuffle(l)

    for i in l:
        r.add(i)

    assert (data, data + 100) in r.acked
Beispiel #11
0
def test_registry_add_starts_range(data):
    from binlog.registry import Registry

    r = Registry()

    assert r.add(data)
    assert r.acked == list([(data, data)])
Beispiel #12
0
def test_registries_support_intersection(data_a, data_b):
    from binlog.registry import Registry

    registry_a = Registry()
    registry_b = Registry()

    for p in data_a:
        registry_a.add(p)

    for p in data_b:
        registry_b.add(p)

    registry_x = registry_a & registry_b

    ack_points = data_a & data_b
    non_ack_points = set(range(0, 20)) - ack_points

    for p in ack_points:
        assert p in registry_x

    for p in non_ack_points:
        assert p not in registry_x