Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

[RFR] Updated bz coverage utility to not update bugs in coverage= marker #10130

Merged
merged 8 commits into from
May 21, 2020
32 changes: 24 additions & 8 deletions cfme/scripting/bz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down