From 54055c8ed0fb985a14cc5d79ab81c1df6972b45b Mon Sep 17 00:00:00 2001 From: Jana Cupova Date: Dec 13 2021 15:34:53 +0000 Subject: Deprecated --paths option in list-buildroot Fixes: https://pagure.io/koji/issue/2473 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 103155d..78a6224 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -2746,13 +2746,15 @@ def anon_handle_list_buildroot(goptions, session, args): "[info] List the rpms used in or built in a buildroot" usage = "usage: %prog list-buildroot [options] " parser = OptionParser(usage=get_usage_str(usage)) - parser.add_option("--paths", action="store_true", help="Show the file paths") + parser.add_option("--paths", action="store_true", help=SUPPRESS_HELP) parser.add_option("--built", action="store_true", help="Show the built rpms") parser.add_option("--verbose", "-v", action="store_true", help="Show more information") (options, args) = parser.parse_args(args) if len(args) != 1: parser.error("Incorrect number of arguments") ensure_connection(session, goptions) + if options.paths: + parser.error("--paths option is deprecated and will be removed in 1.30") buildrootID = int(args[0]) opts = {} if options.built: diff --git a/tests/test_cli/test_list_buildroot.py b/tests/test_cli/test_list_buildroot.py new file mode 100644 index 0000000..cd5bb55 --- /dev/null +++ b/tests/test_cli/test_list_buildroot.py @@ -0,0 +1,57 @@ +from __future__ import absolute_import + +import mock +from six.moves import StringIO + +import koji +from koji_cli.commands import anon_handle_list_buildroot +from . import utils + + +class TestListBuilds(utils.CliTestCase): + def setUp(self): + self.maxDiff = None + self.options = mock.MagicMock() + self.options.debug = False + self.session = mock.MagicMock() + self.session.getAPIVersion.return_value = koji.API_VERSION + self.ensure_connection_mock = mock.patch('koji_cli.commands.ensure_connection').start() + + @mock.patch('sys.stderr', new_callable=StringIO) + def test_list_buildroot_with_paths_option(self, stderr): + expected = """Usage: %s list-buildroot [options] +(Specify the --help global option for a list of other help options) + +%s: error: --paths option is deprecated and will be removed in 1.30 +""" % (self.progname, self.progname) + with self.assertRaises(SystemExit) as ex: + anon_handle_list_buildroot(self.options, self.session, ['--paths', '1']) + self.assertExitCode(ex, 2) + self.assert_console_message(stderr, expected) + self.ensure_connection_mock.assert_called_once_with(self.session, self.options) + + @mock.patch('sys.stderr', new_callable=StringIO) + def test_list_buildroot_without_args(self, stderr): + expected = """Usage: %s list-buildroot [options] +(Specify the --help global option for a list of other help options) + +%s: error: Incorrect number of arguments +""" % (self.progname, self.progname) + with self.assertRaises(SystemExit) as ex: + anon_handle_list_buildroot(self.options, self.session, []) + self.assertExitCode(ex, 2) + self.assert_console_message(stderr, expected) + self.ensure_connection_mock.assert_not_called() + + def test_list_buildroot_help(self): + self.assert_help( + anon_handle_list_buildroot, + """Usage: %s list-buildroot [options] +(Specify the --help global option for a list of other help options) + +Options: + -h, --help show this help message and exit + --built Show the built rpms + -v, --verbose Show more information +""" % self.progname) + self.ensure_connection_mock.assert_not_called()