Integrations

Documentation for all the possible integrations.

Slack integration

class slack_integration.SlackIntegration

Provides automated Slack channel messaging capabilities for test result reporting

__init__()

Initialize the integration with Slack client

_create_payload(results, run_time, testrail_run_id=None, test_run_id=None)

Builds JSON payload containing test run information

Parameters:
  • results – Aggregated test run statistics

  • run_time – Human-readable test execution duration

  • testrail_run_id – Optional TestRail run ID for linking

  • test_run_id – Test run identifier string

Type:

Dictionary

Type:

String

Type:

Integer or None

Type:

String or None

Returns:

None

_get_button_blocks()

Generates action button blocks for Slack message based on active integration configurations

Returns:

JSON payload with integration action buttons

Return type:

Dictionary

_get_environment_url()

Returns the BASE URL for the current environment

Returns:

BASE URL string or environment name as fallback

Return type:

String

_get_platform_emoji()

Returns the appropriate emoji representing the current platform configuration

Returns:

Platform emoji string

Return type:

String

_post_results(payload)

Publishes message to Slack using REST API endpoint for the configured channel

Parameters:

payload – Data formatted in Slack block kit structure

report(results, run_time, testrail_run_id=None, test_run_id=None)

Publishes test results to the configured Slack channel specified in settings.py

Parameters:
  • results – Aggregated test run statistics

  • run_time – Human-readable test execution duration

  • testrail_run_id – Optional TestRail run ID for linking

  • test_run_id – Test run identifier string

Type:

Dictionary

Type:

String

Type:

Integer or None

Type:

String or None

Returns:

None

Saucelabs integration

class saucelabs_integration.SaucelabsHelper
static get_saucelabs_appium_remote(test_case, platform)

Configures and returns a webdriver instance for Saucelabs remote execution with appropriate metadata for test organization :param test_case: A QLTY test case instance :type: QLTYTestcase :param platform: Platform identifier for webdriver configuration :type: String :return: Configured webdriver instance for saucelabs execution :rtype: Webdriver

static post_result(test_case, driver)

Submits test case result to the Saucelabs job record

Parameters:
  • test_case (QLTYTestCase) – A QLTY test case for accessing webdriver

  • driver (Webdriver) – Webdriver for accessing script executor and posting result

TestRail integration

class testrail_integration.TestRailIntegration

Provides TestRail API integration for test result reporting. Enables creation of test runs and submission of test results to TestRail.

__init__()

Initialize the TestRail integration with API credentials from settings

_test_connection()

Tests the connection to TestRail API by making a simple GET request

Raises:

Exception – If connection fails or credentials are invalid

add_attachment_to_result(result_id, file_path)

Attaches a file to a specific test result in TestRail. Supports screenshots, logs, and other artifacts for debugging.

Parameters:
  • result_id (int) – The ID of the test result (returned by add_result_for_case)

  • file_path (str) – Absolute path to the file to attach

Returns:

The attachment response object

Return type:

dict

Raises:

Exception – If attachment upload fails

add_result_for_case(run_id, case_id, status, comment=None, elapsed=None)

Adds a test result for a specific test case in a test run. This method should be called at the end of each test case execution.

Parameters:
  • run_id (int) – The ID of the test run

  • case_id (int) – The ID of the test case (e.g., 69 for case C69)

  • status (str) – The status of the test (passed, failed, blocked, retest, untested)

  • comment (str) – Comment or error message for the result (optional)

  • elapsed (str) – Time elapsed in seconds or time string (e.g., “1m 30s”) (optional)

Returns:

The created test result object

Return type:

dict

Raises:

Exception – If adding result fails

Status values: - ‘passed’ or 1: Test passed - ‘blocked’ or 2: Test blocked - ‘untested’ or 3: Test not executed - ‘retest’ or 4: Test needs retest - ‘failed’ or 5: Test failed

create_test_run(name, description=None, case_ids=None)

Creates a new test run in TestRail with specific test cases or all cases from the suite.

Parameters:
  • name (str) – Name of the test run

  • description (str) – Description of the test run (optional)

  • case_ids (list[int]) – List of specific test case IDs to include in the run (optional)

Returns:

The created test run object containing run_id

Return type:

dict

Raises:

Exception – If test run creation fails

static resolve_case_ids(case_map, config)

Resolve which TestRail case IDs apply based on a case map and a configuration object. Filters out None values and evaluates conditional entries against config flags.

Parameters:
  • case_map (dict) – Dictionary with ‘core’ (always-included cases) and conditional entries keyed by field name. Each conditional entry has: - ‘case_id’: int or None - ‘config_key’: str (flag name to check on config) - ‘inverted’: bool (optional, include when config value is falsy) - ‘config_list’: str (optional, include when config list is non-empty)

  • config – Object with a get_value(key, default=None) method

Returns:

List of applicable TestRail case IDs

Return type:

list[int]

update_run(run_id, case_ids)

Updates a test run to include only specific test cases. This is useful for removing untested cases from the run after execution completes.

Parameters:
  • run_id (int) – The ID of the test run to update

  • case_ids (list) – List of test case IDs to include in the run

Returns:

The updated test run object

Return type:

dict

Raises:

Exception – If update fails

Mailtrap integration

class mailtrap_integration.MailtrapIntegration

Provides Mailtrap email access capabilities for test automation. Enables retrieval and parsing of test emails sent through Mailtrap.

BASE_URL = 'https://mailtrap.io/api'
__init__()

Initialize the Mailtrap helper with API credentials from settings

Extracts the verification/confirmation link from the email body

Parameters:
  • message (dict) – The full message content

  • url_prefix (str or None) – Optional URL prefix to search for (e.g., “https://example.com/verify/”)

Returns:

The verification link URL

Return type:

str

_get_message_content(message_id)

Retrieves the full content of a specific message including HTML and text bodies

Parameters:

message_id (int) – The ID of the message to retrieve

Returns:

Full message content including body

Return type:

dict

_get_messages()

Retrieves all messages from the Mailtrap inbox

Returns:

List of messages

Return type:

list

get_emails_for_recipient(recipient_email, include_content=False)

Retrieves all emails sent to a specific recipient email address.

Parameters:
  • recipient_email (str) – The email address of the recipient

  • include_content (bool) – Whether to fetch full content for each email (default: False)

Returns:

List of emails sent to the recipient

Return type:

list

Retrieves the verification link from the latest email sent to the provided email address.

This method polls the Mailtrap inbox for a new email to the specified recipient, retrieves the most recent message, and extracts the verification/confirmation link from the email body.

Parameters:
  • recipient_email (str) – The email address of the recipient

  • max_wait (int) – Maximum time to wait for email in seconds (default: 30)

  • poll_interval (int) – Time between polling attempts in seconds (default: 2)

  • url_prefix (str or None) – Optional URL prefix to search for (e.g., “https://example.com/verify/”)

Returns:

The verification link URL extracted from the email

Return type:

str

Raises:

Exception – If no email is found or verification link cannot be extracted