From a9559d53479bd6121526d5d220cdaba5304a1bee Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Mar 26 2019 05:29:03 +0000 Subject: Show module build links in output from command module-build If not watch module build, show build links in order to be easy to link to module build in Web browser. Signed-off-by: Chenxiong Qi --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 1ae534c..4a0c487 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -3265,7 +3265,7 @@ class Commands(object): 'The following error occurred while getting information on ' 'module #{0}:\n{1}'.format(nsvc, error_msg)) - def module_get_url(self, build_id, action='GET'): + def module_get_url(self, build_id, action='GET', verbose=True): """ Get the proper MBS API URL for the desired action @@ -3284,7 +3284,8 @@ class Commands(object): url = '{0}'.format(url) if action == 'GET': - url = '{0}?verbose=true'.format(url) + if verbose: + url = '{0}?verbose=true'.format(url) return url @staticmethod diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index a2c5b45..bc3f3e2 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -2066,6 +2066,9 @@ see API KEY section of copr-cli(1) man page. else: ids_to_print = 'build {0} was'.format(str(build_ids[0])) print('The {0} submitted to the MBS' .format(ids_to_print)) + print('Build URLs:') + for build_id in build_ids: + print(self.cmd.module_get_url(build_id, verbose=False)) def module_build_cancel(self): """Cancel an MBS build""" diff --git a/tests/test_cli.py b/tests/test_cli.py index c667f2c..6d5599d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -2042,9 +2042,13 @@ class TestModulesCli(CliTestCase): scopes=self.scopes, timeout=120) output = sys.stdout.getvalue().strip() - expected_output = ('Submitting the module build...\nThe build 1094 ' - 'was submitted to the MBS') - self.assertEqual(output, expected_output) + expected_output = ( + 'Submitting the module build...', + 'The build 1094 was submitted to the MBS', + 'Build URLs:', + cli.cmd.module_get_url(1094, verbose=False), + ) + self.assertEqual(output, '\n'.join(expected_output)) @patch('sys.stdout', new=StringIO()) @patch('requests.get') @@ -2090,9 +2094,15 @@ class TestModulesCli(CliTestCase): scopes=self.scopes, timeout=120) output = sys.stdout.getvalue().strip() - expected_output = ('Submitting the module build...\nThe builds 1094, ' - '1095 and 1096 were submitted to the MBS') - self.assertEqual(output, expected_output) + expected_output = ( + 'Submitting the module build...', + 'The builds 1094, 1095 and 1096 were submitted to the MBS', + 'Build URLs:', + cli.cmd.module_get_url(1094, verbose=False), + cli.cmd.module_get_url(1095, verbose=False), + cli.cmd.module_get_url(1096, verbose=False), + ) + self.assertEqual(output, '\n'.join(expected_output)) @patch('requests.get') @patch('openidc_client.OpenIDCClient.send_request') @@ -2255,9 +2265,13 @@ class TestModulesCli(CliTestCase): cli.module_build() output = sys.stdout.getvalue().strip() - expected_output = ('Submitting the module build...\nThe build 1094 ' - 'was submitted to the MBS') - self.assertEqual(output, expected_output) + expected_output = ( + 'Submitting the module build...', + 'The build 1094 was submitted to the MBS', + 'Build URLs:', + cli.cmd.module_get_url(1094, verbose=False) + ) + self.assertEqual(output, '\n'.join(expected_output)) mock_get.assert_called_once_with( 'https://mbs.fedoraproject.org/module-build-service/1/about/', timeout=60