summaryrefslogtreecommitdiff
path: root/tests/unit/utils.py
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2015-09-22 12:14:18 -0700
committerTim Burke <tim.burke@gmail.com>2015-09-22 12:14:18 -0700
commit305cd6253fc4144e3afece6f39aaaabf68ecb160 (patch)
tree155f60005724b3309c10dc79228f8ca022eda54a /tests/unit/utils.py
parentc90547b5d4304a3f62ba5aa1e78aa620f7dcc1c5 (diff)
downloadpython-swiftclient-305cd6253fc4144e3afece6f39aaaabf68ecb160.tar.gz
Actually make assertions when testing get_account and get_container
Change-Id: Ibb1301b00d1bc99ec089ead02f944aa94972120a
Diffstat (limited to 'tests/unit/utils.py')
-rw-r--r--tests/unit/utils.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/unit/utils.py b/tests/unit/utils.py
index ac9aefd..20272aa 100644
--- a/tests/unit/utils.py
+++ b/tests/unit/utils.py
@@ -325,7 +325,7 @@ class MockHttpTest(testtools.TestCase):
self.orig_assertEqual(body, real_request['body'], err_msg)
if len(expected) > 3:
- headers = expected[3]
+ headers = CaseInsensitiveDict(expected[3])
for key, value in headers.items():
real_request['key'] = key
real_request['expected_value'] = value
@@ -336,16 +336,30 @@ class MockHttpTest(testtools.TestCase):
'for %(method)s %(path)s %(headers)r' % real_request)
self.orig_assertEqual(value, real_request['value'],
err_msg)
+ real_request['extra_headers'] = dict(
+ (key, value) for key, value in real_request['headers'].items()
+ if key not in headers)
+ if real_request['extra_headers']:
+ self.fail('Received unexpected headers for %(method)s '
+ '%(path)s, got %(extra_headers)r' % real_request)
def assertRequests(self, expected_requests):
"""
Make sure some requests were made like you expected, provide a list of
expected requests, typically in the form of [(method, path), ...]
+ or [(method, path, body, headers), ...]
"""
real_requests = self.iter_request_log()
for expected in expected_requests:
real_request = next(real_requests)
self.assert_request_equal(expected, real_request)
+ try:
+ real_request = next(real_requests)
+ except StopIteration:
+ pass
+ else:
+ self.fail('At least one extra request received: %r' %
+ real_request)
def assert_request(self, expected_request):
"""