Make test assertion more holistic

Previously, introducing an error would yield an accurate failure, but
without much context, like

Traceback (most recent call last):
  File "/vagrant/swift/test/unit/proxy/controllers/test_base.py", line 635, in test_headers_to_account_info_storage_policies
    resp['storage_policies'][0]['bytes'], 1002)
KeyError: 'bytes'

Now, we'll have a much larger picture of what's going on:

Traceback (most recent call last):
  File "/vagrant/swift/test/unit/proxy/controllers/test_base.py", line 636, in test_headers_to_account_info_storage_policies
    'bytes': 0},
AssertionError: {0: {'object_count': 13, 'container_count': 120}, 1:
{'object_count': 10, 'conta [truncated]... != {0: {'object_count': 13,
'container_count': 120, 'bytes': 1002}, 1: {'object_cou [truncated]...
- {0: {'container_count': 120, 'object_count': 13},
+ {0: {'bytes': 1002, 'container_count': 120, 'object_count': 13},
?      +++++++++++++++

-  1: {'container_count': 20, 'object_count': 10}}
+  1: {'bytes': 0, 'container_count': 20, 'object_count': 10}}
?      ++++++++++++

Related-Change: I800266d15aabcc7b6e0234de3c9b965b5c15a623
Change-Id: I9a4e5d62674c467bca4bc70d5150d918d48aac42
This commit is contained in:
Tim Burke 2017-08-18 17:27:13 +00:00
parent c653566f4a
commit 72ed76d84b

View File

@ -627,17 +627,14 @@ class TestFuncs(unittest.TestCase):
StoragePolicy(1, 'one', False)])
with PatchPolicies(spc):
resp = headers_to_account_info(headers.items(), 200)
self.assertEqual(
resp['storage_policies'][0]['object_count'], 13)
self.assertEqual(
resp['storage_policies'][0]['container_count'], 120)
self.assertEqual(
resp['storage_policies'][0]['bytes'], 1002)
self.assertEqual(
resp['storage_policies'][1]['object_count'], 10)
self.assertEqual(
resp['storage_policies'][1]['container_count'], 20)
self.assertEqual(resp['storage_policies'][1]['bytes'], 0)
self.assertEqual(resp['storage_policies'], {
0: {'object_count': 13,
'container_count': 120,
'bytes': 1002},
1: {'object_count': 10,
'container_count': 20,
'bytes': 0},
})
def test_headers_to_object_info_missing(self):
resp = headers_to_object_info({}, 404)