Skip to content

Commit 65ea671

Browse files
committed
Add reporter flag
1 parent 4d02eae commit 65ea671

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

jenkins_pipelines/scripts/bsc_list_generator/bsc_finder.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ def parse_cli_args() -> argparse.Namespace:
3838
parser.add_argument("-p", "--product-version", dest="product_version", help="Product version of SUMA you want to run this script for, the options are 4.3 and 5.0. The default is 4.3 for now",
3939
choices=_PRODUCT_VERSIONS, default="4.3", action='store'
4040
)
41-
parser.add_argument("-n", "--release-notes", dest="use_release", default=False, help="Obrain the bugs list from the release notes for the specified SUMA version", action="store_true")
41+
parser.add_argument("-n", "--release-notes", dest="use_release", default=False, help="Obtain the bugs list from the release notes for the specified SUMA version", action="store_true")
4242
parser.add_argument("-c", "--cloud", dest="cloud", default=False, help="Return BSCs for SUMA in Public Clouds", action="store_true")
4343
parser.add_argument("-s", "--status", dest="status", help="Status to filter BSCs by", action="store",
4444
choices=["NEW", "CONFIRMED", "IN_PROGRESS", "RESOLVED"]
4545
)
4646
parser.add_argument("-r", "--resolution", dest="resolution", help="Resolution to filter issues for (default empty string means open bugs)", action="store")
47+
parser.add_argument("-t", "--reporter", dest="reporter", help="Email address of the person who opened the bug to filter issues for", action="store")
4748
# output related flags
4849
parser.add_argument("-o", "--output", dest="output_file", help="File in which the results will be saved", action="store")
4950
parser.add_argument("-f", "--format", dest="output_format", default="txt", help="Output file format (txt default)", action="store",
@@ -104,10 +105,10 @@ def main():
104105
product_versions: list[str] = _PRODUCT_VERSIONS if args.all else [args.product_version]
105106
for version in product_versions:
106107
release_notes_paths: tuple[tuple[str, str, str]] =_IBS_RELEASE_NOTES_FOR_SUMA_VERSION[version]
107-
product_bugs[f"SUSE Manager {version}"] = bugzilla_client.bscs_from_release_notes(release_notes_paths, status = args.status, resolution = args.resolution)
108+
product_bugs[f"SUSE Manager {version}"] = bugzilla_client.bscs_from_release_notes(release_notes_paths, reporter = args.reporter, status = args.status, resolution = args.resolution)
108109
else:
109110
bugzilla_products: list[str] = get_suma_bugzilla_products(args.all, args.product_version, args.cloud)
110-
product_bugs = bugzilla_client.find_suma_bscs(bugzilla_products, status = args.status, resolution = args.resolution)
111+
product_bugs = bugzilla_client.find_suma_bscs(bugzilla_products, reporter = args.reporter, status = args.status, resolution = args.resolution)
111112

112113
output_format: str = args.output_format
113114
output_file: str = args.output_file if args.output_file else _FORMATS_DEFAULT_FILE_NAMES[output_format]

jenkins_pipelines/scripts/tests/test_bsc_finder.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,16 @@ def test_parse_cli_args_default_values(self):
9898
self.assertFalse(args.cloud)
9999
self.assertIsNone(args.status)
100100
self.assertIsNone(args.resolution)
101+
self.assertIsNone(args.reporter)
101102
self.assertIsNone(args.output_file)
102103
self.assertEqual(args.output_format, "txt")
103104

104105
def test_parse_cli_args_success(self):
105106
# shorthand flags
106-
sys.argv = ['bsc_finder.py', "-k", "test_key", "-a", "-p", "5.0", "-n", "-c", "-s", "CONFIRMED", "-r", "", "-o", "test.json", "-f", "json"]
107+
sys.argv = [
108+
'bsc_finder.py', "-k", "test_key", "-a", "-p", "5.0", "-n", "-c", "-s", "CONFIRMED",
109+
"-r", "", "-t", "tester@suse.com", "-o", "test.json", "-f", "json"
110+
]
107111
args = parse_cli_args()
108112

109113
self.assertEqual(args.api_key, "test_key")
@@ -113,13 +117,14 @@ def test_parse_cli_args_success(self):
113117
self.assertTrue(args.cloud)
114118
self.assertEqual(args.status, "CONFIRMED")
115119
self.assertEqual(args.resolution, '')
120+
self.assertEqual(args.reporter, "tester@suse.com")
116121
self.assertEqual(args.output_file, "test.json")
117122
self.assertEqual(args.output_format, "json")
118123

119124
# long flags
120125
sys.argv = [
121126
"bsc_finder.py", "--api-key", "test_key", "--all", "--product-version", "5.0", "--release-notes", "--cloud", "-s", "CONFIRMED",
122-
"--resolution", "", "--output", "test.json", "--format", "json"
127+
"--resolution", "", "--reporter", "tester@suse.com", "--output", "test.json", "--format", "json"
123128
]
124129
args = parse_cli_args()
125130

@@ -130,6 +135,7 @@ def test_parse_cli_args_success(self):
130135
self.assertTrue(args.cloud)
131136
self.assertEqual(args.status, "CONFIRMED")
132137
self.assertEqual(args.resolution, '')
138+
self.assertEqual(args.reporter, "tester@suse.com")
133139
self.assertEqual(args.output_file, "test.json")
134140
self.assertEqual(args.output_format, "json")
135141

jenkins_pipelines/scripts/tests/test_bugzilla_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def setUp(self):
1616
def test_get_bugs_success(self, mock_api_call):
1717
mock_api_call.side_effect = mock_requests_get_success
1818

19-
bugs: list[dict[str, Any]] = self.bugzilla_client._get_bugs(product = "Test Product", status = None, release = None)
19+
bugs: list[dict[str, Any]] = self.bugzilla_client._get_bugs(product = "Test Product", reporter = None, status = None, release = None)
2020
mock_api_call.assert_called_once()
2121
# check None keys are dropped
2222
mock_api_call.assert_called_with(self.bugzilla_client._bugs_endpoint, params = {'Bugzilla_api_key': 'test_key', "product": "Test Product"})
@@ -28,7 +28,7 @@ def test_get_bugs_success(self, mock_api_call):
2828
self.assertEqual(bug['id'], i+1)
2929

3030
# just check the arguments are correctly passed when there's a value
31-
self.bugzilla_client._get_bugs(product = "Test Product", status = "CONFIRMED", release = None)
31+
self.bugzilla_client._get_bugs(product = "Test Product", reporter = None, status = "CONFIRMED", release = None)
3232
mock_api_call.assert_called_with(self.bugzilla_client._bugs_endpoint, params = {'Bugzilla_api_key': 'test_key', "product": "Test Product", "status": "CONFIRMED"})
3333

3434
@patch('requests.get')

0 commit comments

Comments
 (0)