summaryrefslogtreecommitdiff
path: root/tests/unit/test_command_helpers.py
diff options
context:
space:
mode:
authorClay Gerrard <clay.gerrard@gmail.com>2014-09-19 17:07:48 -0700
committerClay Gerrard <clay.gerrard@gmail.com>2014-09-19 17:07:48 -0700
commit40857cfe4c848e3c6bb19a4f0b3987c87d7810b9 (patch)
tree1fe45799c84e92fba43d52c87a3c7550ed5a8539 /tests/unit/test_command_helpers.py
parent8f1b394325804c23ac18e7f9da6cb56a3b95eed2 (diff)
downloadpython-swiftclient-40857cfe4c848e3c6bb19a4f0b3987c87d7810b9.tar.gz
Add per policy container count to account stat output
When the account response includes 'X-Storage-Policy-X-Container-Count' the command helpers will stick a helpful extra line in the output. If the swift response doesn't include the information the behavior is unchanged. Change-Id: Iaaa55d207ebe6a9c16e52adb56eb858c57cfb26a
Diffstat (limited to 'tests/unit/test_command_helpers.py')
-rw-r--r--tests/unit/test_command_helpers.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit/test_command_helpers.py b/tests/unit/test_command_helpers.py
index ad8012e..67e9ac2 100644
--- a/tests/unit/test_command_helpers.py
+++ b/tests/unit/test_command_helpers.py
@@ -124,6 +124,32 @@ Objects in policy "nada": 1000000
"""
self.assertOut(expected)
+ def test_stat_account_policy_stat_with_container_counts(self):
+ # stub head_account
+ stub_headers = {
+ 'x-account-container-count': 42,
+ 'x-account-object-count': 1000000,
+ 'x-account-bytes-used': 2 ** 30,
+ 'x-account-storage-policy-nada-container-count': 10,
+ 'x-account-storage-policy-nada-object-count': 1000000,
+ 'x-account-storage-policy-nada-bytes-used': 2 ** 30,
+ }
+ self.conn.head_account.return_value = stub_headers
+
+ with self.output_manager as output_manager:
+ items, headers = h.stat_account(self.conn, self.options)
+ h.print_account_stats(items, headers, output_manager)
+ expected = """
+ Account: a
+ Containers: 42
+ Objects: 1000000
+ Bytes: 1073741824
+Containers in policy "nada": 10
+ Objects in policy "nada": 1000000
+ Bytes in policy "nada": 1073741824
+"""
+ self.assertOut(expected)
+
def test_stat_container_human(self):
self.options['human'] = True
# stub head container request