From: Daniel Allegood Date: Wed, 27 May 2015 17:27:06 +0000 (-0700) Subject: Updating cmd/manage.py get_arg_string() argument parser and adding unit test X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7cd2d93c45fffc50155fd6833ff3cb267aea7579;p=openstack-build%2Fcinder-build.git Updating cmd/manage.py get_arg_string() argument parser and adding unit test Looks like get_arg_string() would improperly chop off the first two characters of an argument that was passed in with one dash. For example, passing '-option foo' would return 'tion foo' instead of 'option foo'. Change-Id: Ib9aee601711b22c5243aca35f5c6196f494d23a9 Closes-Bug: #1459453 --- diff --git a/cinder/cmd/manage.py b/cinder/cmd/manage.py index 57b5683a7..76f9d7cf6 100644 --- a/cinder/cmd/manage.py +++ b/cinder/cmd/manage.py @@ -514,7 +514,7 @@ def get_arg_string(args): # This is long optional arg arg = args[2:] else: - arg = args[3:] + arg = args[1:] else: arg = args diff --git a/cinder/tests/unit/test_cmd.py b/cinder/tests/unit/test_cmd.py index 8b2a031bc..384d07de8 100644 --- a/cinder/tests/unit/test_cmd.py +++ b/cinder/tests/unit/test_cmd.py @@ -641,6 +641,15 @@ class TestCinderManageCmd(test.TestCase): service_get_all.assert_called_with(ctxt) service_is_up.assert_called_with(service) + def test_get_arg_string(self): + args1 = "foobar" + args2 = "-foo bar" + args3 = "--foo bar" + + self.assertEqual("foobar", cinder_manage.get_arg_string(args1)) + self.assertEqual("foo bar", cinder_manage.get_arg_string(args2)) + self.assertEqual("foo bar", cinder_manage.get_arg_string(args3)) + @mock.patch('oslo_config.cfg.ConfigOpts.register_cli_opt') def test_main_argv_lt_2(self, register_cli_opt): script_name = 'cinder-manage'