cil wrapper-rpm: input check and more reasonable opt --create-draft
This commit is contained in:
parent
c045bc7100
commit
6fe42b6212
2 changed files with 39 additions and 8 deletions
|
|
@ -834,8 +834,8 @@ def handle_wrapper_rpm(options, session, args):
|
|||
parser.add_option("--nowait", action="store_false", dest="wait", help="Don't wait on build")
|
||||
parser.add_option("--background", action="store_true",
|
||||
help="Run the build at a lower priority")
|
||||
parser.add_option("--draft", action="store_true",
|
||||
help="Build draft build instead")
|
||||
parser.add_option("--create-draft", action="store_true",
|
||||
help="Create a new draft build instead")
|
||||
|
||||
(build_opts, args) = parser.parse_args(args)
|
||||
if build_opts.inis:
|
||||
|
|
@ -845,8 +845,12 @@ def handle_wrapper_rpm(options, session, args):
|
|||
if len(args) < 3:
|
||||
parser.error("You must provide a build target, a build ID or NVR, "
|
||||
"and a SCM URL to a specfile fragment")
|
||||
if build_opts.scratch and build_opts.draft:
|
||||
parser.error("--scratch and --draft cannot be both specfied")
|
||||
if build_opts.create_draft:
|
||||
print("Will create a draft build instead")
|
||||
build_opts.create_build = True
|
||||
if build_opts.scratch:
|
||||
# TODO: --scratch and --create-build conflict too
|
||||
parser.error("--scratch and --create-draft cannot be both specfied")
|
||||
activate_session(session, options)
|
||||
|
||||
target = args[0]
|
||||
|
|
@ -882,7 +886,7 @@ def handle_wrapper_rpm(options, session, args):
|
|||
opts['skip_tag'] = True
|
||||
if build_opts.scratch:
|
||||
opts['scratch'] = True
|
||||
if build_opts.draft:
|
||||
if build_opts.create_draft:
|
||||
opts['draft'] = True
|
||||
task_id = session.wrapperRPM(build_id, url, target, priority, opts=opts)
|
||||
print("Created task: %d" % task_id)
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ class TestWrapperRpm(utils.CliTestCase):
|
|||
@mock.patch('koji_cli.commands.activate_session')
|
||||
def test_handle_wrapper_rpm_argument_error(
|
||||
self, activate_session_mock, stderr, stdout):
|
||||
"""Test handle_wrapper_rpm help message output"""
|
||||
"""Test handle_wrapper_rpm error message output"""
|
||||
arguments = []
|
||||
options = mock.MagicMock()
|
||||
|
||||
|
|
@ -219,8 +219,35 @@ class TestWrapperRpm(utils.CliTestCase):
|
|||
# Finally, assert that things were called as we expected.
|
||||
activate_session_mock.assert_not_called()
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
def test_handle_wrapper_rpm_argument_conflict_error(
|
||||
self, activate_session_mock, stderr, stdout):
|
||||
"""Test handle_wrapper_rpm error message output"""
|
||||
arguments = ['--scratch', '--create-draft', 'foo', 'n-v-r', 'scmurl']
|
||||
options = mock.MagicMock()
|
||||
|
||||
# Mock out the xmlrpc server
|
||||
session = mock.MagicMock()
|
||||
|
||||
# Run it and check immediate output
|
||||
expected = self.format_error_message(
|
||||
"--scratch and --create-draft cannot be both specfied")
|
||||
self.assert_system_exit(
|
||||
handle_wrapper_rpm,
|
||||
options,
|
||||
session,
|
||||
arguments,
|
||||
stdout='Will create a draft build instead\n',
|
||||
stderr=expected,
|
||||
activate_session=None)
|
||||
|
||||
# Finally, assert that things were called as we expected.
|
||||
activate_session_mock.assert_not_called()
|
||||
|
||||
def test_handle_wrapper_rpm_help(self):
|
||||
"""Test handle_wrapper_rpm help message output"""
|
||||
"""Test handle_wrapper_rpm help message output"""
|
||||
self.assert_help(
|
||||
handle_wrapper_rpm,
|
||||
"""Usage: %s wrapper-rpm [options] <target> <build-id|n-v-r> <URL>
|
||||
|
|
@ -237,7 +264,7 @@ Options:
|
|||
--wait Wait on build, even if running in the background
|
||||
--nowait Don't wait on build
|
||||
--background Run the build at a lower priority
|
||||
--draft Build draft build instead
|
||||
--create-draft Create a new draft build instead
|
||||
""" % self.progname)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue