Have `delete --all` imply `--versions` for the CLI

Change-Id: Id5a6d4cef3d4ed76c897a099a62a4ba3ed8f8dab
This commit is contained in:
Tim Burke 2020-04-03 09:34:38 -07:00
parent fcd8488ec4
commit 74c50dee2d
2 changed files with 6 additions and 5 deletions

View File

@ -78,8 +78,8 @@ Positional arguments:
for multiple objects. for multiple objects.
Optional arguments: Optional arguments:
-a, --all Delete all containers and objects. -a, --all Delete all containers and objects. Implies --versions.
--versions Delete all versions --versions Delete all versions.
--leave-segments Do not delete segments of manifest objects. --leave-segments Do not delete segments of manifest objects.
-H, --header <header:value> -H, --header <header:value>
Adds a custom request header to use for deleting Adds a custom request header to use for deleting
@ -132,6 +132,8 @@ def st_delete(parser, args, output_manager, return_parser=False):
(options, args) = parse_args(parser, args) (options, args) = parse_args(parser, args)
args = args[1:] args = args[1:]
if options['yes_all']:
options['versions'] = True
if (not args and not options['yes_all']) or (args and options['yes_all']): if (not args and not options['yes_all']) or (args and options['yes_all']):
output_manager.error('Usage: %s delete %s\n%s', output_manager.error('Usage: %s delete %s\n%s',
BASENAME, st_delete_options, BASENAME, st_delete_options,

View File

@ -1260,8 +1260,7 @@ class TestShell(unittest.TestCase):
[None, [{'name': 'empty_container'}]], [None, [{'name': 'empty_container'}]],
[None, []], [None, []],
] ]
# N.B: missing --versions flag, version-id gets ignored # N.B: --all implies --versions, clear it all out
# only latest object is deleted
connection.return_value.get_container.side_effect = [ connection.return_value.get_container.side_effect = [
[None, [{'name': 'object'}, {'name': 'obj\xe9ct2'}]], [None, [{'name': 'object'}, {'name': 'obj\xe9ct2'}]],
[None, []], [None, []],
@ -1279,7 +1278,7 @@ class TestShell(unittest.TestCase):
response_dict={}, headers={}), response_dict={}, headers={}),
mock.call('container', 'obj\xe9ct2', query_string='', mock.call('container', 'obj\xe9ct2', query_string='',
response_dict={}, headers={}), response_dict={}, headers={}),
mock.call('container2', 'object', query_string='', mock.call('container2', 'object', query_string='version-id=1',
response_dict={}, headers={})], any_order=True) response_dict={}, headers={})], any_order=True)
self.assertEqual(3, connection.return_value.delete_object.call_count, self.assertEqual(3, connection.return_value.delete_object.call_count,
'Expected 3 calls but found\n%r' 'Expected 3 calls but found\n%r'