summaryrefslogtreecommitdiffstats
path: root/result_collection_api/tests/unit/test_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'result_collection_api/tests/unit/test_base.py')
-rw-r--r--result_collection_api/tests/unit/test_base.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/result_collection_api/tests/unit/test_base.py b/result_collection_api/tests/unit/test_base.py
index b72436e..98190fb 100644
--- a/result_collection_api/tests/unit/test_base.py
+++ b/result_collection_api/tests/unit/test_base.py
@@ -1,3 +1,4 @@
+import json
from tornado.web import Application
from tornado.testing import AsyncHTTPTestCase
@@ -7,6 +8,12 @@ import fake_pymongo
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(
[
@@ -28,9 +35,20 @@ class TestBase(AsyncHTTPTestCase):
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()