コード例 #1
0
def test_module_dictgenerator_num_elements():

    actor_config = ActorConfig('template', 100, 1, {}, "")
    dictgenerator = DictGenerator(actor_config, min_elements=1, max_elements=2)

    dictgenerator.pool.queue.outbox.disableFallThrough()
    dictgenerator.start()

    event = getter(dictgenerator.pool.queue.outbox)

    assert len(event.get().keys()) >= 1 and len(event.get().keys()) <= 2
コード例 #2
0
def test_module_dictgenerator_randomize_keys():

    actor_config = ActorConfig('template', 100, 1, {}, "")
    dictgenerator = DictGenerator(actor_config, randomize_keys=False)

    dictgenerator.pool.queue.outbox.disableFallThrough()
    dictgenerator.start()

    event = getter(dictgenerator.pool.queue.outbox)

    assert '0' in event.get().keys()
コード例 #3
0
def test_module_dictgenerator_keys():

    actor_config = ActorConfig('template', 100, 1, {}, "")
    dictgenerator = DictGenerator(actor_config, keys=["one", "two"])

    dictgenerator.pool.queue.outbox.disableFallThrough()
    dictgenerator.start()

    event = getter(dictgenerator.pool.queue.outbox)

    assert "one" in event.get().keys()
    assert "two" in event.get().keys()
コード例 #4
0
def test_module_dictgenerator_num_values():

    actor_config = ActorConfig('template', 100, 1, {}, "")
    dictgenerator = DictGenerator(actor_config, num_values=True, num_values_min=1, num_values_max=2)

    dictgenerator.pool.queue.outbox.disableFallThrough()
    dictgenerator.start()

    event = getter(dictgenerator.pool.queue.outbox)

    for key, value in event.get().items():
        assert isinstance(value, int)

    assert isinstance(list(event.get().items())[0][1], int)
    assert list(event.get().items())[0][1] >= 1 and list(event.get().items())[0][1] <= 2