summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2020-04-03 09:34:38 -0700
committerTim Burke <tim.burke@gmail.com>2020-10-16 13:57:02 -0700
commit74c50dee2de1fdda0d58cc295a70c7ff7d1700e6 (patch)
tree8bd80b1a1d82919030ad3964c9a35f702327d0ed
parentfcd8488ec455e43efaae86284820bad22e515b1b (diff)
downloadpython-swiftclient-74c50dee2de1fdda0d58cc295a70c7ff7d1700e6.tar.gz
Have `delete --all` imply `--versions` for the CLI
Change-Id: Id5a6d4cef3d4ed76c897a099a62a4ba3ed8f8dab
-rwxr-xr-xswiftclient/shell.py6
-rw-r--r--test/unit/test_shell.py5
2 files changed, 6 insertions, 5 deletions
diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index dbcd437..7c6f0f7 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -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,
diff --git a/test/unit/test_shell.py b/test/unit/test_shell.py
index 46ba52c..8c525d9 100644
--- a/test/unit/test_shell.py
+++ b/test/unit/test_shell.py
@@ -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'