Merge "Error if arguments are not supplied for rename commands"
This commit is contained in:
@@ -127,7 +127,7 @@ class ShellTest(utils.TestCase):
|
|||||||
'status=available&volume_id=1234')
|
'status=available&volume_id=1234')
|
||||||
|
|
||||||
def test_rename(self):
|
def test_rename(self):
|
||||||
# basic rename with positional agruments
|
# basic rename with positional arguments
|
||||||
self.run_command('rename 1234 new-name')
|
self.run_command('rename 1234 new-name')
|
||||||
expected = {'volume': {'display_name': 'new-name'}}
|
expected = {'volume': {'display_name': 'new-name'}}
|
||||||
self.assert_called('PUT', '/volumes/1234', body=expected)
|
self.assert_called('PUT', '/volumes/1234', body=expected)
|
||||||
@@ -143,12 +143,12 @@ class ShellTest(utils.TestCase):
|
|||||||
'display_description': 'new-description',
|
'display_description': 'new-description',
|
||||||
}}
|
}}
|
||||||
self.assert_called('PUT', '/volumes/1234', body=expected)
|
self.assert_called('PUT', '/volumes/1234', body=expected)
|
||||||
# noop, the only all will be the lookup
|
|
||||||
self.run_command('rename 1234')
|
# Call rename with no arguments
|
||||||
self.assert_called('GET', '/volumes/1234')
|
self.assertRaises(SystemExit, self.run_command, 'rename')
|
||||||
|
|
||||||
def test_rename_snapshot(self):
|
def test_rename_snapshot(self):
|
||||||
# basic rename with positional agruments
|
# basic rename with positional arguments
|
||||||
self.run_command('snapshot-rename 1234 new-name')
|
self.run_command('snapshot-rename 1234 new-name')
|
||||||
expected = {'snapshot': {'display_name': 'new-name'}}
|
expected = {'snapshot': {'display_name': 'new-name'}}
|
||||||
self.assert_called('PUT', '/snapshots/1234', body=expected)
|
self.assert_called('PUT', '/snapshots/1234', body=expected)
|
||||||
@@ -165,9 +165,9 @@ class ShellTest(utils.TestCase):
|
|||||||
'display_description': 'new-description',
|
'display_description': 'new-description',
|
||||||
}}
|
}}
|
||||||
self.assert_called('PUT', '/snapshots/1234', body=expected)
|
self.assert_called('PUT', '/snapshots/1234', body=expected)
|
||||||
# noop, the only all will be the lookup
|
|
||||||
self.run_command('snapshot-rename 1234')
|
# Call snapshot-rename with no arguments
|
||||||
self.assert_called('GET', '/snapshots/1234')
|
self.assertRaises(SystemExit, self.run_command, 'snapshot-rename')
|
||||||
|
|
||||||
def test_set_metadata_set(self):
|
def test_set_metadata_set(self):
|
||||||
self.run_command('metadata 1234 set key1=val1 key2=val2')
|
self.run_command('metadata 1234 set key1=val1 key2=val2')
|
||||||
|
@@ -105,7 +105,7 @@ class ShellTest(utils.TestCase):
|
|||||||
'status=available&volume_id=1234')
|
'status=available&volume_id=1234')
|
||||||
|
|
||||||
def test_rename(self):
|
def test_rename(self):
|
||||||
# basic rename with positional agruments
|
# basic rename with positional arguments
|
||||||
self.run_command('rename 1234 new-name')
|
self.run_command('rename 1234 new-name')
|
||||||
expected = {'volume': {'name': 'new-name'}}
|
expected = {'volume': {'name': 'new-name'}}
|
||||||
self.assert_called('PUT', '/volumes/1234', body=expected)
|
self.assert_called('PUT', '/volumes/1234', body=expected)
|
||||||
@@ -121,12 +121,12 @@ class ShellTest(utils.TestCase):
|
|||||||
'description': 'new-description',
|
'description': 'new-description',
|
||||||
}}
|
}}
|
||||||
self.assert_called('PUT', '/volumes/1234', body=expected)
|
self.assert_called('PUT', '/volumes/1234', body=expected)
|
||||||
# noop, the only all will be the lookup
|
|
||||||
self.run_command('rename 1234')
|
# Call rename with no arguments
|
||||||
self.assert_called('GET', '/volumes/1234')
|
self.assertRaises(SystemExit, self.run_command, 'rename')
|
||||||
|
|
||||||
def test_rename_snapshot(self):
|
def test_rename_snapshot(self):
|
||||||
# basic rename with positional agruments
|
# basic rename with positional arguments
|
||||||
self.run_command('snapshot-rename 1234 new-name')
|
self.run_command('snapshot-rename 1234 new-name')
|
||||||
expected = {'snapshot': {'name': 'new-name'}}
|
expected = {'snapshot': {'name': 'new-name'}}
|
||||||
self.assert_called('PUT', '/snapshots/1234', body=expected)
|
self.assert_called('PUT', '/snapshots/1234', body=expected)
|
||||||
@@ -143,9 +143,9 @@ class ShellTest(utils.TestCase):
|
|||||||
'description': 'new-description',
|
'description': 'new-description',
|
||||||
}}
|
}}
|
||||||
self.assert_called('PUT', '/snapshots/1234', body=expected)
|
self.assert_called('PUT', '/snapshots/1234', body=expected)
|
||||||
# noop, the only all will be the lookup
|
|
||||||
self.run_command('snapshot-rename 1234')
|
# Call snapshot-rename with no arguments
|
||||||
self.assert_called('GET', '/snapshots/1234')
|
self.assertRaises(SystemExit, self.run_command, 'snapshot-rename')
|
||||||
|
|
||||||
def test_set_metadata_set(self):
|
def test_set_metadata_set(self):
|
||||||
self.run_command('metadata 1234 set key1=val1 key2=val2')
|
self.run_command('metadata 1234 set key1=val1 key2=val2')
|
||||||
|
@@ -323,6 +323,11 @@ def do_rename(cs, args):
|
|||||||
kwargs['display_name'] = args.display_name
|
kwargs['display_name'] = args.display_name
|
||||||
if args.display_description is not None:
|
if args.display_description is not None:
|
||||||
kwargs['display_description'] = args.display_description
|
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)
|
utils.find_volume(cs, args.volume).update(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
@@ -467,6 +472,11 @@ def do_snapshot_rename(cs, args):
|
|||||||
kwargs['display_name'] = args.display_name
|
kwargs['display_name'] = args.display_name
|
||||||
if args.display_description is not None:
|
if args.display_description is not None:
|
||||||
kwargs['display_description'] = args.display_description
|
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)
|
_find_volume_snapshot(cs, args.snapshot).update(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -362,6 +362,10 @@ def do_rename(cs, args):
|
|||||||
elif args.description is not None:
|
elif args.description is not None:
|
||||||
kwargs['description'] = args.description
|
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)
|
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:
|
elif args.display_description is not None:
|
||||||
kwargs['description'] = args.display_description
|
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)
|
_find_volume_snapshot(cs, args.snapshot).update(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user