示例#1
0
def test_response_list_build_and_set(random_string):
    response_list = jgt_common.ResponseList()

    assert len(response_list) == 0
    response_list.build_and_set(response=random_string)
    assert len(response_list) == 1
    assert isinstance(response_list.single_item, jgt_common.ResponseInfo)
示例#2
0
def test_response_list_run_response_callbacks():
    arbitrary_list_len = random.randint(1, 10)  # Anything > 0 is fine.
    response_list = jgt_common.ResponseList()

    response_list.extend(
        jgt_common.ResponseInfo(response_callback=arbitrary_callback)
        for x in range(arbitrary_list_len))
    arbitrary_callback_counter[0] = 0
    response_list.run_response_callbacks()
    assert arbitrary_callback_counter[0] == arbitrary_list_len
示例#3
0
def test_responselist_set():
    arbitrary_list_len = random.randint(1, 10)  # Anything > 0 is fine.
    my_list = jgt_common.ResponseList()
    my_list.extend(range(arbitrary_list_len))
    assert len(my_list) == arbitrary_list_len
    my_list.set([])
    assert len(my_list) == 0
    my_list.set([-1, -2])
    assert len(my_list) == 2
    assert my_list == [-1, -2]
示例#4
0
def test_responselist_single_item():
    my_list = jgt_common.ResponseList()
    with pytest.raises(AssertionError):
        my_list.single_item

    my_list.append(3)
    assert my_list.single_item == 3

    my_list.append(4)
    with pytest.raises(AssertionError):
        my_list.single_item