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_transform_data_in_tabular_str_with_dict_data():
    data = {
        'name': 'Test: process data for print',
        'status_code': '200',
        'headers': '{Content-Type: application/json}',
        'body': 'Lorem Ipsum'
    }
    tabular_str = core.transform_data_in_tabular_str(data)

    assert isinstance(tabular_str, str)