def test_create_many():
    fake_storage = {}
    length = 1
    count = 400  # way more than we can do with this name length
    max_seen_length = 0
    for i in range_type(count):
        name = ItemName.create(fake_storage, length=length, max_length=length*4, max_tries=10)
        # use the name in storage, so it is not available any more
        fake_storage[name] = None
        max_seen_length = max(max_seen_length, len(name))
    # it should automatically use longer names, if it runs out of unique names:
    assert max_seen_length > length
    # we should get all unique names we wanted, no duplicates:
    assert len(list(fake_storage)) == count
Esempio n. 2
0
def test_make_id_unique():
    length, count = 6, 10000
    ids = set(make_id(length) for i in range_type(count))
    # if we did not encounter duplicates, set size must be <count>
    # of course, in extremely rare cases, this test might fail
    assert len(ids) == count
Esempio n. 3
0
def test_make_id_length():
    for length in range_type(10):
        assert len(make_id(length)) == length
Esempio n. 4
0
def test_make_id_unique():
    length, count = 6, 10000
    ids = set(make_id(length) for i in range_type(count))
    # if we did not encounter duplicates, set size must be <count>
    # of course, in extremely rare cases, this test might fail
    assert len(ids) == count
Esempio n. 5
0
def test_make_id_length():
    for length in range_type(10):
        assert len(make_id(length)) == length