+import json
from tornado.web import Application
from tornado.testing import AsyncHTTPTestCase
class TestBase(AsyncHTTPTestCase):
+ headers = {'Content-Type': 'application/json; charset=UTF-8'}
+
+ def setUp(self):
+ self.addCleanup(self._clear)
+ super(TestBase, self).setUp()
+
def get_app(self):
return Application(
[
debug=True,
)
- def tearDown(self):
- yield fake_pymongo.pod.remove()
- yield fake_pymongo.test_projects.remove()
- yield fake_pymongo.test_cases.remove()
- yield fake_pymongo.test_results.remove()
- super(TestBase, self).tearDown()
+ def create(self, uri, body=None):
+ return self.fetch(uri,
+ method='POST',
+ body=json.dumps(body),
+ headers=self.headers)
+
+ def get(self, uri):
+ return self.fetch(uri,
+ method='GET',
+ headers=self.headers)
+
+ @staticmethod
+ def _clear():
+ fake_pymongo.pod.clear()
+ fake_pymongo.test_projects.clear()
+ fake_pymongo.test_cases.clear()
+ fake_pymongo.test_results.clear()