diff options
author | Yuan Zhou <yuan.zhou@intel.com> | 2014-07-31 19:51:50 +0800 |
---|---|---|
committer | Yuan Zhou <yuan.zhou@intel.com> | 2014-08-06 16:07:17 +0800 |
commit | 776133bd299adfb644f2274143b9fba72672428d (patch) | |
tree | 2d76f05f20192657353e2445fe1f082aedcb4d6c /tests/unit/test_command_helpers.py | |
parent | fd1594937d777c0047051ae470e2de5523522171 (diff) | |
download | python-swiftclient-776133bd299adfb644f2274143b9fba72672428d.tar.gz |
Clean up raw policy stats in account stat
Storage policy stats was not well parsed in account stat. This
patch parses the stats and print out the stats in a format like below:
$swift -A http://swift_cluster/auth/v1.0 -U test:tester -K testing stat
Account: AUTH_test
Containers: 5
Objects: 1
Bytes: 2097152
Objects in policy "golden": 1
Bytess in policy "golden": 2097152
Objects in policy "silver": 0
Bytes in policy "silver": 0
X-Timestamp: 1404697760.88809
X-Trans-Id: txec519e24b44a413abb705-0053da2dcb
Content-Type: text/plain; charset=utf-8
Accept-Ranges: bytes
Change-Id: I7ad0ee6d88f8393e3a93e90cd52b9b592da7072d
Diffstat (limited to 'tests/unit/test_command_helpers.py')
-rw-r--r-- | tests/unit/test_command_helpers.py | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/tests/unit/test_command_helpers.py b/tests/unit/test_command_helpers.py index af81601..8bb9dc1 100644 --- a/tests/unit/test_command_helpers.py +++ b/tests/unit/test_command_helpers.py @@ -69,10 +69,10 @@ class TestStatHelpers(testtools.TestCase): with self.thread_manager as thread_manager: h.stat_account(self.conn, self.options, thread_manager) expected = """ - Account: a - Containers: 42 - Objects: 976K - Bytes: 1.0G + Account: a +Containers: 42 + Objects: 976K + Bytes: 1.0G """ self.assertOut(expected) @@ -89,12 +89,35 @@ class TestStatHelpers(testtools.TestCase): with self.thread_manager as thread_manager: h.stat_account(self.conn, self.options, thread_manager) expected = """ - StorageURL: http://storage/v1/a - Auth Token: tk12345 - Account: a - Containers: 42 - Objects: 1000000 - Bytes: 1073741824 +StorageURL: http://storage/v1/a +Auth Token: tk12345 + Account: a +Containers: 42 + Objects: 1000000 + Bytes: 1073741824 +""" + self.assertOut(expected) + + def test_stat_account_policy_stat(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-object-count': 1000000, + 'x-account-storage-policy-nada-bytes-used': 2 ** 30, + } + self.conn.head_account.return_value = stub_headers + + with self.thread_manager as thread_manager: + h.stat_account(self.conn, self.options, thread_manager) + expected = """ + Account: a + Containers: 42 + Objects: 1000000 + Bytes: 1073741824 +Objects in policy "nada": 1000000 + Bytes in policy "nada": 1073741824 """ self.assertOut(expected) |