def test_max_gen_always_return_increasing_ids(): gen = IdMaxGenerator() pid0 = gen.get_id(11) pid1 = gen.get_id() assert pid1 > pid0 gen.release_id(pid1) assert gen.get_id() > pid1
def test_max_gen_start_at_zero(): gen = IdMaxGenerator() assert gen.get_id() == 0
def test_max_gen_clear_restart_from_zero(): gen = IdMaxGenerator() pid0 = gen.get_id(12) gen.clear() assert gen.get_id() == 0 assert gen.get_id(pid0) == pid0
def test_max_gen_raise_error_if_asked_twice_for_the_same_id(): gen = IdMaxGenerator() gen.get_id(10) assert_raises(IndexError, lambda: gen.get_id(10))
def test_max_gen_does_not_return_twice_the_same_value(): gen = IdMaxGenerator() pid0 = gen.get_id() assert gen.get_id() > pid0