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.')
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.")
def validate_config(self): if self.args.report: rep_s = validate_section('Test_rail') if len(rep_s) > 0: logger.warning( '{}. Report tests to TestRail was disabled.'.format(rep_s)) self.args.report = False bugzilla_s = validate_section('Bugzilla') if len(bugzilla_s) > 0: logger.warning( '{}. Tests blocked by Bugzilla issues will be automatically skipped.' .format(bugzilla_s)) git_hub_s = validate_section('GitHub') if len(bugzilla_s) > 0: logger.warning( '{}. Tests blocked by GitHub issues will be automatically skipped.' .format(git_hub_s))
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
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