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.
Optional arguments:
-a, --all Delete all containers and objects.
--versions Delete all versions
-a, --all Delete all containers and objects. Implies --versions.
--versions Delete all versions.
--leave-segments Do not delete segments of manifest objects.
-H, --header <header:value>
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)
args = args[1:]
if options['yes_all']:
options['versions'] = True
if (not args and not options['yes_all']) or (args and options['yes_all']):
output_manager.error('Usage: %s delete %s\n%s',
BASENAME, st_delete_options,

View File

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