# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. """
This script contains utility functions designed to support the integration of automated
testing processes with TestRail, a test case management tool. The primary focus is on
creating and managing milestones in TestRail based on automated smoke tests for product
releases. It includes functions for building milestone names and descriptions, determining
release types, and loading TestRail credentials.
Functions:
- build_milestone_name(product_type, release_type, version_number): Constructs a formatted
milestone name based on the product type, release type, and version number.
- build_milestone_description(milestone_name): Generates a detailed description for the
milestone, including the release date and placeholders for testing status and QA recommendations.
- get_release_version(): Reads and returns the release version number from a 'version.txt' file.
- get_release_type(version): Determines the release type (e.g., Alpha, Beta, RC) based on
the version string.
- load_testrail_credentials(json_file_path): Loads TestRail credentials from a JSON file and handles potential errors during the loading process. """
import json import os import textwrap from datetime import datetime
def get_release_version(): # Check if version.txt was found
version_file_path = os.path.join(
os.environ.get("GECKO_PATH", "."), "mobile", "android", "version.txt"
) ifnot os.path.isfile(version_file_path): raise FileNotFoundError(f"{version_file_path} not found.")
# Read the version from the file with open(version_file_path, "r") as file:
version = file.readline().strip()
return version
def get_release_type(version):
release_map = {"a": "Alpha", "b": "Beta"} # use generator expression to check each char for key else default to 'RC'
product_type = next(
(release_map[char] for char in version if char in release_map), "RC"
) return product_type
def load_testrail_credentials(json_file_path): try: with open(json_file_path, "r") as file:
credentials = json.load(file) return credentials except json.JSONDecodeError as e: raise ValueError(f"Failed to load TestRail credentials: {e}")
¤ Dauer der Verarbeitung: 0.30 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.