Make config options required
Since we're not providing a default, we should make the --config-file and --kolla-config options required to ensure that people don't execute it without options and wonder why nothing occured. Change-Id: If6df69de9c0ded8b9f8975adfe8cd63cb619ca05 Closes-Bug: #1699158
This commit is contained in:
parent
6030cd1ab6
commit
e1a4458061
tripleoclient
@ -27,18 +27,18 @@ class TestContainerImageUpload(TestPluginV1):
|
|||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = container_image.UploadImage(self.app, None)
|
self.cmd = container_image.UploadImage(self.app, None)
|
||||||
|
|
||||||
|
@mock.patch('sys.exit')
|
||||||
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager',
|
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test_container_image_upload_noargs(self, mock_manager):
|
def test_container_image_upload_noargs(self, mock_manager, exit_mock):
|
||||||
arglist = []
|
arglist = []
|
||||||
verifylist = []
|
verifylist = []
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
|
# argparse will complain that --config-file is missing and exit with 2
|
||||||
mock_manager.assert_called_once_with([])
|
exit_mock.assert_called_with(2)
|
||||||
mock_manager.return_value.upload.assert_called_once_with()
|
|
||||||
|
|
||||||
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager',
|
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@ -68,18 +68,19 @@ class TestContainerImageBuild(TestPluginV1):
|
|||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = container_image.BuildImage(self.app, None)
|
self.cmd = container_image.BuildImage(self.app, None)
|
||||||
|
|
||||||
|
@mock.patch('sys.exit')
|
||||||
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test_container_image_build_noargs(self, mock_builder):
|
def test_container_image_build_noargs(self, mock_builder, exit_mock):
|
||||||
arglist = []
|
arglist = []
|
||||||
verifylist = []
|
verifylist = []
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
|
# argparse will complain that --config-file and --kolla-config are
|
||||||
mock_builder.assert_called_once_with([])
|
# missing exit with 2
|
||||||
mock_builder.return_value.build_images.assert_called_once_with([])
|
exit_mock.assert_called_with(2)
|
||||||
|
|
||||||
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
|
@ -36,6 +36,7 @@ class UploadImage(command.Command):
|
|||||||
metavar='<yaml config file>',
|
metavar='<yaml config file>',
|
||||||
default=[],
|
default=[],
|
||||||
action="append",
|
action="append",
|
||||||
|
required=True,
|
||||||
help=_("YAML config file specifying the image build. May be "
|
help=_("YAML config file specifying the image build. May be "
|
||||||
"specified multiple times. Order is preserved, and later "
|
"specified multiple times. Order is preserved, and later "
|
||||||
"files will override some options in previous files. "
|
"files will override some options in previous files. "
|
||||||
@ -64,6 +65,7 @@ class BuildImage(command.Command):
|
|||||||
metavar='<yaml config file>',
|
metavar='<yaml config file>',
|
||||||
default=[],
|
default=[],
|
||||||
action="append",
|
action="append",
|
||||||
|
required=True,
|
||||||
help=_("YAML config file specifying the images to build. May be "
|
help=_("YAML config file specifying the images to build. May be "
|
||||||
"specified multiple times. Order is preserved, and later "
|
"specified multiple times. Order is preserved, and later "
|
||||||
"files will override some options in previous files. "
|
"files will override some options in previous files. "
|
||||||
@ -75,6 +77,7 @@ class BuildImage(command.Command):
|
|||||||
metavar='<config file>',
|
metavar='<config file>',
|
||||||
default=[],
|
default=[],
|
||||||
action="append",
|
action="append",
|
||||||
|
required=True,
|
||||||
help=_("Path to a Kolla config file to use. Multiple config files "
|
help=_("Path to a Kolla config file to use. Multiple config files "
|
||||||
"can be specified, with values in later files taking "
|
"can be specified, with values in later files taking "
|
||||||
"precedence."),
|
"precedence."),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user