Merge "Fix condition in CheckSizeArgForCreate parser action"

This commit is contained in:
Jenkins
2015-06-12 11:25:28 +00:00
committed by Gerrit Code Review
2 changed files with 9 additions and 2 deletions

View File

@@ -334,6 +334,13 @@ class ShellTest(utils.TestCase):
def test_create_size_required_if_not_snapshot_or_clone(self):
self.assertRaises(SystemExit, self.run_command, 'create')
def test_create_size_zero_if_not_snapshot_or_clone(self):
expected = {'volume': {'status': 'creating',
'size': 0}}
self.run_command('create 0')
self.assert_called_anytime('POST', '/volumes', partial_body=expected)
self.assert_called('GET', '/volumes/1234')
def test_show(self):
self.run_command('show 1234')
self.assert_called('GET', '/volumes/1234')

View File

@@ -261,8 +261,8 @@ def do_show(cs, args):
class CheckSizeArgForCreate(argparse.Action):
def __call__(self, parser, args, values, option_string=None):
if (values or args.snapshot_id or args.source_volid
or args.source_replica) is None:
if ((args.snapshot_id or args.source_volid or args.source_replica)
is None and values is None):
parser.error('Size is a required parameter if snapshot '
'or source volume is not specified.')
setattr(args, self.dest, values)