Esempio n. 1
0
def test_remove():
    generator = IDGenerator(init_val=101)
    assert (generator.next() == 101)
    generator.remove_id(102)
    generator.remove_id(104)
    generator.remove_id(106)
    assert (generator.next() == 103)
    assert (generator.next() == 105)
    assert (generator.next() == 107)
Esempio n. 2
0
def test_contains():
    generator = IDGenerator(init_val=10)
    gids = [generator.next() for _ in range(10)]
    assert (len(gids) == 10)
    assert (10 in generator)
    assert (19 in generator)
    assert (20 not in generator)

    generator.remove_id(54678)
    assert (54678 in generator)
    assert (54677 not in generator)
    assert (54679 not in generator)
    generator.remove_id(54677)
    assert (54677 in generator)