Exemplo n.º 1
0
def test_check_response_status_code_add_info(client_err, expected_description):
    info_key = generate_random_string()
    info_value = generate_random_string()
    actual_msg = http_helpers.check_response_status_code(
        expected_description,
        client_err,
        additional_info={info_key: info_value})
    assert_.is_in(info_key, actual_msg)
    assert_.is_in(info_value, actual_msg)
Exemplo n.º 2
0
def test_simple_responseinfo_data():
    response = jgt_common.generate_random_string()
    description = jgt_common.generate_random_string()
    extra_field = jgt_common.generate_random_string()
    a_response = jgt_common.ResponseInfo(response=response,
                                         description=description,
                                         extra_field=extra_field)
    assert a_response.response == response
    assert a_response.description == description
    assert a_response.extra_field == extra_field
    # No callbacks, so the response data should just be the response
    assert a_response.response_data == response
Exemplo n.º 3
0
def uuids_with_extra_text():
    target_uuid = str(uuid4())
    extra_text = jgt_common.generate_random_string()
    return [
        extra_text + target_uuid,
        extra_text + target_uuid + extra_text,
        target_uuid + extra_text,
    ]
Exemplo n.º 4
0
def uuids_with_isolated_extra_text():
    target_uuid = str(uuid4())
    extra_text = jgt_common.generate_random_string()
    return [
        target_uuid,
        "/" + target_uuid,
        extra_text + "-" + target_uuid + "-",
        target_uuid + "/" + extra_text,
    ]
Exemplo n.º 5
0
def random_string():
    """
    Generate a random string.

    Build something arbitrary and random that doesn't collide with
    ARBITRARY_CALLBACK_VALUE
    """
    # making the value larger ensures it won't collide.
    return jgt_common.generate_random_string(
        size=len(ARBITRARY_CALLBACK_VALUE) + 1)
Exemplo n.º 6
0
def test_invalid_json_with_message(bad_json):
    random_text = generate_random_string()
    with pytest.raises(AssertionError) as e:
        http_helpers.safe_json_from(bad_json, description=random_text)
    assert random_text in str(e.value)
Exemplo n.º 7
0
def test_invalid_keys():
    key = jgt_common.generate_random_string()
    expected_msg = "{} is not one of: {}".format(
        key, _sorted_key_names(KEY_TEST_DICT["nested"]))
    with pytest.raises(KeyError, match=expected_msg):
        jgt_common.must_get_keys(KEY_TEST_DICT, "nested", key)
Exemplo n.º 8
0
def test_random_string_default_choose_from():
    text = jgt_common.generate_random_string()
    assert set(text) <= set(RANDOM_STRING_DEFAULT_CHOOSE_FROM)
Exemplo n.º 9
0
def test_string_size_failure():
    with pytest.raises(AssertionError):
        jgt_common.generate_random_string(prefix="this-is-a-long-prefix-",
                                          suffix="-this-is-a-long-suffix",
                                          size=3)
Exemplo n.º 10
0
def test_random_string_default_size():
    text = jgt_common.generate_random_string()
    assert len(text) == RANDOM_STRING_DEFAULT_SIZE
Exemplo n.º 11
0
def test_random_string_choose_from():
    # Using only symbols to avoid any overlap with the default choose_from
    non_default_choose_from = "(_)+-*&$#@"
    text = jgt_common.generate_random_string(
        choose_from=non_default_choose_from)
    assert set(text) <= set(non_default_choose_from)
Exemplo n.º 12
0
def test_random_string_suffix():
    suffix = "-test"
    text = jgt_common.generate_random_string(suffix=suffix)
    assert text.endswith(suffix)
Exemplo n.º 13
0
def test_random_string_prefix():
    prefix = "test-"
    text = jgt_common.generate_random_string(prefix=prefix)
    assert text.startswith(prefix)
Exemplo n.º 14
0
def test_random_string_length():
    non_default_size = RANDOM_STRING_DEFAULT_SIZE + 5
    text = jgt_common.generate_random_string(size=non_default_size)
    assert len(text) == non_default_size