diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-05-18 13:32:50 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-05-18 17:25:53 +0800 |
commit | 6f3276ffc0066193c19d6b098d12d4af25509f9d (patch) | |
tree | 772d9c1b4a0f480400ebbf9eaaf88e6758de7858 /result_collection_api/tests/unit/test_base.py | |
parent | d719f7428de763767b491b983ce214c329ba37b1 (diff) |
add pod related unittests in testAPI
unittest for create/get/list pod in testAPI project
JIRA: FUNCTEST-252
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Change-Id: Ifedb4715abffda20c93284ef58cd93f584879af8
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'result_collection_api/tests/unit/test_base.py')
-rw-r--r-- | result_collection_api/tests/unit/test_base.py | 30 |
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() |