From ba4315f4ef7b11a540101fa4d743b804c4c42da0 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Aug 27 2018 12:46:41 +0000 Subject: Allow the ':' separator for NSVCs. ... because that's how things work now. --- diff --git a/module_diff/mbs.py b/module_diff/mbs.py index e904018..c7f7c61 100644 --- a/module_diff/mbs.py +++ b/module_diff/mbs.py @@ -9,10 +9,11 @@ class MBS(object): self.params = {'verbose': 'true'} def get_module(self, nsvc): - name = nsvc.split("-")[0:-3] - stream = nsvc.split("-")[-3] - version = nsvc.split("-")[-2] - context = nsvc.split("-")[-1] + sep = ':' if ':' in nsvc else '-' + name = nsvc.split(sep)[0:-3] + stream = nsvc.split(sep)[-3] + version = nsvc.split(sep)[-2] + context = nsvc.split(sep)[-1] params = dict(self.params) params.update({'name': name, 'stream': stream, 'version': version, 'context': context}) res = requests.get(self.mbs_url, params=params) diff --git a/tests/test_cli.py b/tests/test_cli.py index 0bb29a3..0887123 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -88,6 +88,29 @@ class TestCli(object): assert "RPMs which dist tag changed" not in output assert "RPMs Reused" not in output + def test_cli_colon_delimited(self, mbs_json_res, capsys): + """ Test that we can handle colon delimited NSVC. """ + + module1_res, module2_res = generate_module_res(mbs_json_res) + + with requests_mock.mock() as mock_http: + mock_http.register_uri("GET", module1_url, json=module1_res) + mock_http.register_uri("GET", module2_url, json=module2_res) + + cli_cmd = [ + 'module_diff', + 'mariadb:10.2:20171019133930:00000000', + 'mariadb:10.2:20171103103655:00000000' + ] + + with mock.patch("sys.argv", cli_cmd): + main() + output = capsys.readouterr()[0] + + check_common_output(output) + assert "RPMs which dist tag changed" not in output + assert "RPMs Reused" not in output + def test_cli_dist_option(self, mbs_json_res, capsys): """ Testing option --dist which displays RPMs which changed their dist tag.