summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2021-04-08 17:16:05 -0700
committerTim Burke <tim.burke@gmail.com>2021-09-21 08:40:45 -0700
commitad3e8e49d072d8137c85c451db427d07e1301799 (patch)
treea59222eb9ad5f317f37379397786d31a9fdb8fba
parent5129b33505691f5c4a3e33f2878b157cbd5b4a62 (diff)
downloadpython-swiftclient-ad3e8e49d072d8137c85c451db427d07e1301799.tar.gz
Include storage policy when listing account with --long
Change-Id: Ibc2f9445b5a8e80cfb73d0706e20a7e4c62eec4a
-rwxr-xr-xswiftclient/shell.py5
-rw-r--r--test/unit/test_shell.py20
2 files changed, 15 insertions, 10 deletions
diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index cf90ffc..1878272 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -550,10 +550,11 @@ def st_list(parser, args, output_manager, return_parser=False):
datestamp = strftime('%Y-%m-%d %H:%M:%S', utc)
except TypeError:
datestamp = '????-??-?? ??:??:??'
+ storage_policy = meta.get('x-storage-policy', '???')
if not options['totals']:
output_manager.print_msg(
- "%12s %s %s %s", count, byte_str,
- datestamp, item_name)
+ "%12s %s %s %-15s %s", count, byte_str,
+ datestamp, storage_policy, item_name)
else: # list container contents
subdir = item.get('subdir')
content_type = item.get('content_type')
diff --git a/test/unit/test_shell.py b/test/unit/test_shell.py
index 84dd681..0cf2258 100644
--- a/test/unit/test_shell.py
+++ b/test/unit/test_shell.py
@@ -467,6 +467,10 @@ class TestShell(unittest.TestCase):
[None, [{'name': 'container', 'bytes': 0, 'count': 0}]],
[None, []],
]
+ connection.return_value.head_container.return_value = {
+ 'x-timestamp': '1617393213.49752',
+ 'x-storage-policy': 'some-policy',
+ }
argv = ["", "list", "--lh"]
with CaptureOutput() as output:
@@ -475,10 +479,10 @@ class TestShell(unittest.TestCase):
mock.call(marker='container', prefix=None, headers={})]
connection.return_value.get_account.assert_has_calls(calls)
- self.assertEqual(
- output.out,
- ' 0 0 1970-01-01 00:00:01 container\n'
- ' 0 0\n')
+ self.assertEqual(
+ output.out,
+ ' 0 0 2021-04-02 19:53:33 some-policy container\n'
+ ' 0 0\n')
# Now test again, this time without returning metadata
connection.return_value.head_container.return_value = {}
@@ -496,10 +500,10 @@ class TestShell(unittest.TestCase):
mock.call(marker='container', prefix=None, headers={})]
connection.return_value.get_account.assert_has_calls(calls)
- self.assertEqual(
- output.out,
- ' 0 0 ????-??-?? ??:??:?? container\n'
- ' 0 0\n')
+ self.assertEqual(
+ output.out,
+ ' 0 0 ????-??-?? ??:??:?? ??? container\n'
+ ' 0 0\n')
def test_list_account_totals_error(self):
# No --lh provided: expect info message about incorrect --totals use