diff options
Diffstat (limited to 'tests/unit/utils.py')
-rw-r--r-- | tests/unit/utils.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/unit/utils.py b/tests/unit/utils.py index 1bfa8da..3b043bc 100644 --- a/tests/unit/utils.py +++ b/tests/unit/utils.py @@ -87,17 +87,19 @@ def fake_http_connect(*code_iter, **kwargs): def __init__(self, status, etag=None, body='', timestamp='1', headers=None): - self.status = status + self.status_code = self.status = status self.reason = 'Fake' + self.scheme = 'http' self.host = '1.2.3.4' self.port = '1234' self.sent = 0 self.received = 0 self.etag = etag - self.body = body + self.content = self.body = body self.timestamp = timestamp self._is_closed = True self.headers = headers or {} + self.request = None def getresponse(self): if kwargs.get('raise_exc'): @@ -223,15 +225,18 @@ class MockHttpTest(unittest.TestCase): pass conn = RequestsWrapper() - def request(method, url, *args, **kwargs): + def request(method, path, *args, **kwargs): try: conn.resp = self.fake_connect() except StopIteration: self.fail('Unexpected %s request for %s' % ( - method, url)) - self.request_log.append((parsed, method, url, args, + method, path)) + self.request_log.append((parsed, method, path, args, kwargs, conn.resp)) conn.host = conn.resp.host + conn.resp.request = RequestsWrapper() + conn.resp.request.url = '%s://%s%s' % ( + conn.resp.scheme, conn.resp.host, path) conn.resp.has_been_read = False _orig_read = conn.resp.read @@ -240,15 +245,15 @@ class MockHttpTest(unittest.TestCase): return _orig_read(*args, **kwargs) conn.resp.read = read if on_request: - status = on_request(method, url, *args, **kwargs) + status = on_request(method, path, *args, **kwargs) conn.resp.status = status if auth_token: headers = args[1] self.assertEqual(auth_token, headers.get('X-Auth-Token')) if query_string: - self.assertTrue(url.endswith('?' + query_string)) - if url.endswith('invalid_cert') and not insecure: + self.assertTrue(path.endswith('?' + query_string)) + if path.endswith('invalid_cert') and not insecure: from swiftclient import client as c raise c.ClientException("invalid_certificate") if exc: |