Example #1
0
def get_bugzilla_bug(bug_id):
    """Get Bugzilla bug details."""
    if len(validate_section("Bugzilla")) > 0:
        return None

    bugzilla_api_key = get_config_property("Bugzilla", "api_key")
    base_url = get_config_property("Bugzilla", "bugzilla_url")

    try:
        b = bugzilla.Bugzilla(url=base_url, api_key=bugzilla_api_key)
        return b.get_bug(bug_id)
    except Exception:
        return None
Example #2
0
    def send_json_report(self):
        report_s = validate_section('Report_URL')
        if len(report_s) > 0:
            logger.warning(
                '{}. \nJSON report cannot be sent - no report URL found in config file.'
                .format(report_s))
        else:
            run_file = os.path.join(PathManager.get_current_run_dir(),
                                    'run.json')
            url = get_config_property('Report_URL', 'url')
            if url is not None:
                try:
                    with open(run_file, 'rb') as file:
                        r = requests.post(url=url, files={'file': file})

                    if not r.ok:
                        logger.error(
                            'Report was not sent to URL: %s \nResponse text: %s'
                            % url, r.text)

                    logger.debug('Sent JSON report status: %s' % r.text)
                except requests.RequestException as ex:
                    logger.error(
                        'Failed to send run report to URL: %s \nException data: %s'
                        % url, ex)
            else:
                logger.error('Bad URL for JSON report.')
Example #3
0
class TestSuiteMap:
    suite_dictionary = ast.literal_eval(
        get_config_property("Test_rail", "suite_dictionary"))

    suite_name = ""

    def __init__(self, suite_id, test_results_list):
        """

        :param suite_id: TestRail suite id
        :param test_results_list: a list of TestRailTests objects

        """
        self.suite_id = suite_id
        self.test_results_list = test_results_list
        self.get_suite_name()

    def get_suite_name(self):
        """
        Method that will parse config.ini and retrieve the suite name from
        suite_dictionary

        """
        for key in self.suite_dictionary:
            if self.suite_id == self.suite_dictionary.get(key):
                self.suite_name = key
Example #4
0
    def send_json_report(self):
        report_s = validate_section("Report_URL")
        if len(report_s) > 0:
            logger.warning(
                "{}. \nJSON report cannot be sent - no report URL found in config file."
                .format(report_s))
        else:
            run_file = os.path.join(PathManager.get_current_run_dir(),
                                    "run.json")
            url = get_config_property("Report_URL", "url")
            if url is not None:
                try:
                    with open(run_file, "rb") as file:
                        r = requests.post(url=url, files={"file": file})

                    if not r.ok:
                        logger.error(
                            "Report was not sent to URL: %s \nResponse text: %s"
                            % url, r.text)

                    logger.debug("Sent JSON report status: %s" % r.text)
                except requests.RequestException as ex:
                    logger.error(
                        "Failed to send run report to URL: %s \nException data: %s"
                        % url, ex)
            else:
                logger.error("Bad URL for JSON report.")
Example #5
0
def get_github_issue(bug_id):
    """Get Github issues details."""
    if len(validate_section('GitHub')) > 0:
        return None

    github_api_key = Github(get_config_property('GitHub', 'github_key'))

    try:
        repo = [x for x in github_api_key.get_user().get_repos() if x.name == 'iris2']
        return repo[0].get_issue(bug_id)
    except Exception:
        return None
Example #6
0
 def __init__(self):
     logger.info("Starting email reporting.")
     self.email_host = get_config_property("Email", "smtp_ssl_host")
     self.email_port = get_config_property("Email", "smtp_ssl_port")
     self.username = get_config_property("Email", "username")
     self.password = get_config_property("Email", "password")
     self.sender = get_config_property("Email", "sender")
     self.targets = ast.literal_eval(get_config_property(
         "Email", "targets"))
Example #7
0
    def generate_test_suite_collection_objects(test_rail_tests: list):
        """
        :param test_rail_tests: a list of TestRailTest
        :return: a list of TestSuiteMap
        """
        test_suite_array = []
        suite_dictionary = ast.literal_eval(
            get_config_property("Test_rail", "suite_dictionary"))
        suite_ids = []
        for suite in suite_dictionary:
            suite_ids.append(suite_dictionary.get(suite))
        for suite_id in suite_ids:
            test_case_ids = []
            for test_result in test_rail_tests:
                if isinstance(test_result, TestRailTests):
                    if suite_id == test_result.section_id:
                        test_case_ids.append(test_result)
            if not test_case_ids:
                continue
            else:
                test_suite_object = TestSuiteMap(suite_id, test_case_ids)
                test_suite_array.append(test_suite_object)

        return test_suite_array
Example #8
0
 def __init__(self):
     logger.info("Starting TestRail reporting.")
     self.test_rail_url = get_config_property("Test_rail", "test_rail_url")
     self.client = api_client.APIClient(self.test_rail_url)
     self.client.user = get_config_property("Test_rail", "username")
     self.client.password = get_config_property("Test_rail", "password")
Example #9
0
def get_update_rules():
    """Returns the 'update_rules' config property from the 'Update' section."""
    rules = get_config_property("Update", "update_rules")
    if rules is None:
        return None
    return ast.literal_eval(rules)
Example #10
0
 def __init__(self):
     logger.info('Starting TestRail reporting.')
     self.test_rail_url = get_config_property('Test_rail', 'test_rail_url')
     self.client = api_client.APIClient(self.test_rail_url)
     self.client.user = get_config_property('Test_rail', 'username')
     self.client.password = get_config_property('Test_rail', 'password')