Monty Taylor 06acb0c009 Move from unittest2 to testtools
Part of blueprint grizzly-testtools

Change-Id: I13e068ca156f12114eaa3a65bdb557e4eb2c988d
2012-12-24 23:39:32 -06:00

34 lines
869 B
Python

import testtools
import requests
class TestCase(testtools.TestCase):
TEST_REQUEST_BASE = {
'config': {'danger_mode': False},
'verify': True,
}
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