Skip to content

Report API

This page describes the ReportAPI class.

APIException

Bases: Exception

Raise when API call returns error status code

InvalidDataException

Bases: Exception

Raise when invalid data

InvalidPathException

Bases: Exception

Raise when invalid directory or file path

ReportAPI

Class that allows for interacting with reports via API.

Attributes:

Name Type Description
client object

client for sending requests to Typhoon Test Hub API

generate_and_upload_report(results_dir, execution_id, multiple_results=False, tags=None)

Generate an Allure report based on Allure results

Parameters:

Name Type Description Default
results_dir string

Path to directory containing Allure results

required
execution_id int

Identifier of execution to which report should be assigned

required
multiple_results bool

Indicator whether results_dir points to directory with multiple Allure results which requires merging multiple Allure results into single Allure report

False
tags list

List of execution tags where each tag is a string value

None

Returns:

Name Type Description
identifier int

Identifier of created report

Raises:

Type Description
APIException

Response status code not 201

InvalidPathException

Invalid report path provided

InvalidDataException

Invalid data provided

get_info(report_id, details=False)

Obtain details of the Report with the provided report identifier.

Parameters:

Name Type Description Default
report_id int

Identifier of report

required
details bool

Include report details like executed tests results and metrics (the default value is False)

False

Returns:

Name Type Description
data dict

Report information

Raises:

Type Description
APIException

Response status code not 200

upload_report(report_path, execution_id, report_type='allure', tags=None, summary=None, summary_json=None, test_results=None, test_results_json=None, metrics=None, metrics_json=None)

Upload a report to Typhoon Test Hub.

Parameters:

Name Type Description Default
report_path str

Path to directory or file containing report

required
execution_id int

Identifier of the Execution to which the report should be assigned

required
report_type str

Type of report; can be one of the following values:

  • allure - requires for report_path value to be an Allure report
  • html - requires for report_path value to be a directory with html page
  • pdf - requires for report_path value to be a pdf file
  • custom - requires for report_path value to be a file or a directory that will be saved as a zip archive
'allure'
tags list

List of execution tags where each tag is a string value

None
summary dict

Summary of report; dict with the following structure:

{
    "started_at": datetime_instance,
    "ended_at": datetime_instance,
    "failed": number_of_failed_tests,
    "broken": number_of_broken_tests,
    "passed": number_of_passed_tests,
    "skipped": number_of_skipped_tests,
    "unknown": number_of_unknown_tests
}

each of the keys is optional - for started_at and ended_at the default value is the current datetime, and for numbered parameters the default value is 0

None
summary_json str

Path to JSON file containing summary; if summary parameter is defined, this parameter is ignored; if the started_at or ended_at parameters are provided, they should be dates in ISO 8601 format (the default value is the current datetime) while the numbered parameters if provided should be positive non-negative integers (the default value is 0)

None
test_results list

List that contains results of all executed tests. Each element of the list should be a dictionary that represents a test suite with following three keys:

  • name (mandatory) - unique suite name
  • uid (optional) - suite identifier
  • tests (mandatory) - list of test results.

Each element of test results (tests collection for each suite) should be a dictionary that represents a test with following three keys:

  • name (mandatory) - unique test name inside the suite
  • uid (optional) - test identifier
  • status (mandatory) - status of test; can be one of the following values (case-insensitive): PASSED, FAILED, BROKEN, SKIPPED, UNKNOWN (default value)
  • assertions (optional) - dict of individual assertions, where the key is assertion identifier and value is status of assertion (PASSED, FAILED, BROKEN, SKIPPED, or UNKNOWN).

Example of the results object:

[
    {
        "name": "suite_1",
        "uid": "s1",
        "tests": [
            {
                "name": "test_a",
                "uid": "t_a",
                "status": "PASSED"
            },
            {
                "name": "test_b",
                "uid": "t_b",
                "status": "FAILED"
                "assertions": {
                    "first_assertion": "PASSED",
                    "second_assertion": "FAILED"
                }
            }
        ]
    },
    {
        "name": "suite_2",
        "uid": "s2",
        "tests": [
            {
                "name": "test_c",
                "uid": "t_c",
                "status": "BROKEN"
            }
        ]
    }
]
None
test_results_json str

Path to JSON file containing results; if test_results parameter is defined, this parameter is ignored

None
metrics dict

Dictionary that contains metrics of test session. Keys of the dictionary are group names and values are dictionaries with metric names as dictionary keys and recorded metric values as dictionary values. Metric value can be an instance of string, integer, or float.

Example of the metrics object:

{
    "group_1": {
        "metric_1_name": "foo",
        "metric_2_name": 234
    },
    "group_2": {
        "metric_1_name": "bar",
        "metric_2_name": 88
    }
}
None
metrics_json str

Path to JSON file containing metrics; if matrics parameter is defined, this parameter is ignored

None

Returns:

Name Type Description
identifier int

Identifier of created report

Raises:

Type Description
APIException

Response status code not 201

UnsupportedReportTypeException

Invalid report type

InvalidPathException

Invalid report path provided

InvalidDataException

Invalid data provided

upload_results(results_path, execution_id, multiple_results=False, tags=None)

Upload Allure results to Typhoon Test Hub.

Parameters:

Name Type Description Default
results_path str

Path to directory containing Allure results

required
execution_id int

Identifier of the Execution to which the report should be assigned

required
multiple_results bool

Indicator that results_path contains multiple Allure results (the default value is False)

False
tags list

List of execution tags where each tag is a string value

None

Returns:

Name Type Description
identifier int

Identifier of created report

Raises:

Type Description
APIException

Response status code not 201

InvalidPathException

Invalid report path provided

InvalidDataException

Invalid data provided

UnsupportedReportTypeException

Bases: Exception

Raise when invalid report type chosen