def execute_test_scenarios(file):
    """Wrapper function that executes single or multiple
    test scenarios according to the content from file.

    :param str file_path: Optional file path.

    :returns: Text output with the result.
    :rtype: `str'
    """
    try:
        list_of_content = core.load_content_from_json_file(file)
        # Actually, the zeroth index contains the content
        content = list_of_content[0]

        # Depends on a type of the content loaded from the file,
        # the business logic for single or multiple test scenarios
        # is executed.
        if isinstance(content, dict):
            result = execute_single_test_scenario(content)
        elif isinstance(content, list):
            result = execute_multiple_test_scenarios(content)
    except Exception as exc:
        return str(exc)

    return core.transform_data_in_tabular_str(result)
예제 #2
0
def test_load_content_from_json_file_with_multiple_http_requests_scenarios():
    content = core.load_content_from_json_file(
        'data/MULTIPLE_HTTP_REQUESTS.json')

    assert isinstance(content[0], list)
예제 #3
0
def test_extract_json_data_with_key_name_response():
    content = core.load_content_from_json_file(
        'data/HTTP_GET_SAVE_RESPONSE.json')
    required_args, optional_kwargs = core.extract_json_data(content[0])

    assert 'response' in optional_kwargs and optional_kwargs['response']
예제 #4
0
def test_extract_json_data():
    content = core.load_content_from_json_file('data/HTTP_GET.json')
    required_args, optional_kwargs = core.extract_json_data(content[0])

    assert isinstance(required_args, tuple) and isinstance(
        optional_kwargs, dict)
예제 #5
0
def test_load_content_from_json_file_with_not_supported_file_extension():
    with pytest.raises(FileExtensionError) as exc:
        core.load_content_from_json_file('data/HTTP_GET.yaml')

    assert 'is not supported' in str(exc.value)
예제 #6
0
def test_load_content_from_json_file():
    content = core.load_content_from_json_file('data/HTTP_GET.json')

    assert isinstance(content[0], dict)