summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/utils.py11
-rw-r--r--tests/v3/utils.py28
2 files changed, 11 insertions, 28 deletions
diff --git a/tests/utils.py b/tests/utils.py
index 16eeecc..b3c4dc4 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -128,12 +128,15 @@ class TestResponse(requests.Response):
def __init__(self, data):
self._text = None
- super(TestResponse, self)
+ super(TestResponse, self).__init__()
if isinstance(data, dict):
self.status_code = data.get('status_code', None)
- self.headers = data.get('headers', None)
+ headers = data.get('headers')
+ if headers:
+ self.headers.update(headers)
# Fake the text attribute to streamline Response creation
- self._text = data.get('text', None)
+ # _content is defined by requests.Response
+ self._content = data.get('text', None)
else:
self.status_code = data
@@ -142,4 +145,4 @@ class TestResponse(requests.Response):
@property
def text(self):
- return self._text
+ return self.content
diff --git a/tests/v3/utils.py b/tests/v3/utils.py
index 76a83f1..0f4afbd 100644
--- a/tests/v3/utils.py
+++ b/tests/v3/utils.py
@@ -9,8 +9,12 @@ import mox
import requests
import testtools
+from .. import utils
+
from keystoneclient.v3 import client
+TestResponse = utils.TestResponse
+
def parameterize(ref):
"""Rewrites attributes to match the kwarg naming convention in client.
@@ -361,27 +365,3 @@ class CrudTests(testtools.TestCase):
self.mox.ReplayAll()
self.manager.delete(ref['id'])
-
-
-class TestResponse(requests.Response):
- """Class used to wrap requests.Response and provide some
- convenience to initialize with a dict.
- """
-
- def __init__(self, data):
- self._text = None
- super(TestResponse, self)
- if isinstance(data, dict):
- self.status_code = data.get('status_code', None)
- self.headers = data.get('headers', None)
- # Fake the text attribute to streamline Response creation
- self._text = data.get('text', None)
- else:
- self.status_code = data
-
- def __eq__(self, other):
- return self.__dict__ == other.__dict__
-
- @property
- def text(self):
- return self._text