From 2b7a842ed7e34099f1c4eb6d222bc814ff4d26b8 Mon Sep 17 00:00:00 2001 From: PJ Richardson <52798694+prichard77@users.noreply.github.com> Date: Thu, 21 May 2020 08:02:43 -0400 Subject: [PATCH] [RFR] Updated bz coverage utility to not update bugs in coverage= marker (#10130) * Updated bz coveraage utility to not update flags for bugs in coverage= and replaced log msg with exception when no bz creds * Remove remaining coverage references * Remove changes to bz.py * Remove changes to bzs.py * Add option --inc_man to coverage() and set option to false by default * Add check for user or key attributes and error out if both are missing * Apply suggestions from code review Updating arg to include_manual Co-authored-by: john-dupuy <44065123+john-dupuy@users.noreply.github.com> * Update cfme/scripting/bz.py missed one of the include_manual changes Co-authored-by: Mike Shriver Co-authored-by: john-dupuy <44065123+john-dupuy@users.noreply.github.com> --- cfme/scripting/bz.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/cfme/scripting/bz.py b/cfme/scripting/bz.py index c08c9234b2..146cb8209c 100644 --- a/cfme/scripting/bz.py +++ b/cfme/scripting/bz.py @@ -30,6 +30,7 @@ from cfme.utils import conf from cfme.utils.blockers import BZ +from cfme.utils.bz import Bugzilla from cfme.utils.log import logger from cfme.utils.path import data_path from cfme.utils.version import current_version @@ -44,18 +45,24 @@ BZ_URL = conf.env.bugzilla.url -def get_report(directory): +def get_report(directory, include_manual=True): + bz_instance = Bugzilla.from_config() + if not (bz_instance.user or bz_instance.key): + msg = ("ERROR: Credentials key for bugzilla does not have username or api key.") + click.secho(msg, err=True, bold=True, fg="red") + sys.exit(0) click.echo("Generating a BZ report in bz-report.yaml") - pytest.main([ - "--use-provider", "complete", + options = ["--use-provider", "complete", "--long-running", "--use-template-cache", "--collect-only", "--dummy-appliance", - "--include-manual", "-q", - "--generate-bz-report", directory - ]) + "--generate-bz-report" + ] + if include_manual: + options.append("--include-manual") + pytest.main(options.append(directory)) # read the generated yaml try: with open("bz-report.yaml") as stream: @@ -224,6 +231,15 @@ def list(directory, bz_status): @main.command(help="Set QE test coverage flag based on automates/coverage metadata") @click.argument("directory", default="cfme/tests") +@click.option( + "-m", + "--include-manual", + "include_manual", + is_flag=True, + help="Include BZs that are marked in coverage test metadata for manual tests", + default=False, + show_default=True +) @click.option( "-s", "--set", @@ -263,8 +279,8 @@ def list(directory, bz_status): show_default=True, flag_value="closed_bzs" ) -def coverage(directory, set_bzs, bz_status): - info = get_report(directory) +def coverage(directory, include_manual, set_bzs, bz_status): + info = get_report(directory, include_manual=include_manual) # get list of bzs that should have test coverage set bz_list = get_qe_test_coverage(info, bz_status)