Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion elliott/elliottlib/cli/find_bugs_qe_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ def close_reconciliation_bugs(runtime, noop: bool, bug_tracker):
status=statuses,
include_labels=['art:reconciliation'],
)
bugs = bug_tracker._search(query, verbose=runtime.debug)
if query is None:
# All configured target versions were filtered out (e.g. not yet defined in JIRA
# for a new release). _query() already logged why; nothing to search for.
bugs = []
else:
bugs = bug_tracker._search(query, verbose=runtime.debug)
LOGGER.info(f"Found {len(bugs)} bugs to close: {', '.join(sorted(str(b.id) for b in bugs))}")

close_comment = (
Expand Down
19 changes: 19 additions & 0 deletions elliott/tests/test_find_bugs_qe_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,25 @@ def test_close_reconciliation_bugs_noop(self):

close_reconciliation_bugs(runtime, True, bug_tracker)

def test_close_reconciliation_bugs_no_valid_target_versions(self):
"""_query returns None when all configured target versions are filtered out
(e.g. not yet defined in JIRA for a new release). close_reconciliation_bugs
must treat that as "no bugs found" instead of searching with a None query,
which JIRA rejects as an unbounded query."""
runtime = flexmock(debug=False)
client = flexmock()
bug_tracker = flexmock(type='jira', _client=client)
flexmock(bug_tracker).should_receive("target_release").and_return(["5.1.0", "5.1.z", "5.1"])
flexmock(bug_tracker).should_receive("_query").with_args(
status=RECONCILIATION_STATUSES,
include_labels=['art:reconciliation'],
).and_return(None).once()
flexmock(bug_tracker).should_receive("_search").never()
flexmock(client).should_receive("transition_issue").never()
flexmock(bug_tracker).should_receive("add_comment").never()

close_reconciliation_bugs(runtime, False, bug_tracker)


if __name__ == '__main__':
unittest.main()
Loading