Merge "Error if arguments are not supplied for rename commands"

This commit is contained in:
Jenkins
2013-10-03 23:35:23 +00:00
committed by Gerrit Code Review
4 changed files with 34 additions and 16 deletions

View File

@@ -127,7 +127,7 @@ class ShellTest(utils.TestCase):
'status=available&volume_id=1234')
def test_rename(self):
# basic rename with positional agruments
# basic rename with positional arguments
self.run_command('rename 1234 new-name')
expected = {'volume': {'display_name': 'new-name'}}
self.assert_called('PUT', '/volumes/1234', body=expected)
@@ -143,12 +143,12 @@ class ShellTest(utils.TestCase):
'display_description': 'new-description',
}}
self.assert_called('PUT', '/volumes/1234', body=expected)
# noop, the only all will be the lookup
self.run_command('rename 1234')
self.assert_called('GET', '/volumes/1234')
# Call rename with no arguments
self.assertRaises(SystemExit, self.run_command, 'rename')
def test_rename_snapshot(self):
# basic rename with positional agruments
# basic rename with positional arguments
self.run_command('snapshot-rename 1234 new-name')
expected = {'snapshot': {'display_name': 'new-name'}}
self.assert_called('PUT', '/snapshots/1234', body=expected)
@@ -165,9 +165,9 @@ class ShellTest(utils.TestCase):
'display_description': 'new-description',
}}
self.assert_called('PUT', '/snapshots/1234', body=expected)
# noop, the only all will be the lookup
self.run_command('snapshot-rename 1234')
self.assert_called('GET', '/snapshots/1234')
# Call snapshot-rename with no arguments
self.assertRaises(SystemExit, self.run_command, 'snapshot-rename')
def test_set_metadata_set(self):
self.run_command('metadata 1234 set key1=val1 key2=val2')

View File

@@ -105,7 +105,7 @@ class ShellTest(utils.TestCase):
'status=available&volume_id=1234')
def test_rename(self):
# basic rename with positional agruments
# basic rename with positional arguments
self.run_command('rename 1234 new-name')
expected = {'volume': {'name': 'new-name'}}
self.assert_called('PUT', '/volumes/1234', body=expected)
@@ -121,12 +121,12 @@ class ShellTest(utils.TestCase):
'description': 'new-description',
}}
self.assert_called('PUT', '/volumes/1234', body=expected)
# noop, the only all will be the lookup
self.run_command('rename 1234')
self.assert_called('GET', '/volumes/1234')
# Call rename with no arguments
self.assertRaises(SystemExit, self.run_command, 'rename')
def test_rename_snapshot(self):
# basic rename with positional agruments
# basic rename with positional arguments
self.run_command('snapshot-rename 1234 new-name')
expected = {'snapshot': {'name': 'new-name'}}
self.assert_called('PUT', '/snapshots/1234', body=expected)
@@ -143,9 +143,9 @@ class ShellTest(utils.TestCase):
'description': 'new-description',
}}
self.assert_called('PUT', '/snapshots/1234', body=expected)
# noop, the only all will be the lookup
self.run_command('snapshot-rename 1234')
self.assert_called('GET', '/snapshots/1234')
# Call snapshot-rename with no arguments
self.assertRaises(SystemExit, self.run_command, 'snapshot-rename')
def test_set_metadata_set(self):
self.run_command('metadata 1234 set key1=val1 key2=val2')

View File

@@ -323,6 +323,11 @@ def do_rename(cs, args):
kwargs['display_name'] = args.display_name
if args.display_description is not None:
kwargs['display_description'] = args.display_description
if not any(kwargs):
msg = 'Must supply either display-name or display-description.'
raise exceptions.ClientException(code=1, message=msg)
utils.find_volume(cs, args.volume).update(**kwargs)
@@ -467,6 +472,11 @@ def do_snapshot_rename(cs, args):
kwargs['display_name'] = args.display_name
if args.display_description is not None:
kwargs['display_description'] = args.display_description
if not any(kwargs):
msg = 'Must supply either display-name or display-description.'
raise exceptions.ClientException(code=1, message=msg)
_find_volume_snapshot(cs, args.snapshot).update(**kwargs)

View File

@@ -362,6 +362,10 @@ def do_rename(cs, args):
elif args.description is not None:
kwargs['description'] = args.description
if not any(kwargs):
msg = 'Must supply either name or description.'
raise exceptions.ClientException(code=1, message=msg)
utils.find_volume(cs, args.volume).update(**kwargs)
@@ -527,6 +531,10 @@ def do_snapshot_rename(cs, args):
elif args.display_description is not None:
kwargs['description'] = args.display_description
if not any(kwargs):
msg = 'Must supply either name or description.'
raise exceptions.ClientException(code=1, message=msg)
_find_volume_snapshot(cs, args.snapshot).update(**kwargs)