Deprecated --paths option in list-buildroot

Fixes: https://pagure.io/koji/issue/2473
This commit is contained in:
Jana Cupova 2021-11-01 10:50:05 +01:00 committed by Tomas Kopecek
parent d83a7631eb
commit 54055c8ed0
2 changed files with 60 additions and 1 deletions

View file

@ -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] <buildroot-id>"
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:

View file

@ -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] <buildroot-id>
(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] <buildroot-id>
(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] <buildroot-id>
(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()