diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-05-23 18:34:19 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-05-25 15:14:28 +0800 |
commit | 0c898e11323cf4e5baabecb55d8be2ff2268690d (patch) | |
tree | 85860cd1859ebcfc6c877c115acecbab8b2c5266 /result_collection_api/tests/unit/test_fake_pymongo.py | |
parent | 12ef6fc908872a2c8f52b53d3f2527d98365fd91 (diff) |
add test result/dashboard related unittests in testAPI and refactor its response
modification:
add unittests for test result/dashboard
rename test_results table name in db to results
refactor response body
JIRA: FUNCTEST-255
Change-Id: I0657e6e95156a8c79072e7333fd8aaeb12d986e5
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'result_collection_api/tests/unit/test_fake_pymongo.py')
-rw-r--r-- | result_collection_api/tests/unit/test_fake_pymongo.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/result_collection_api/tests/unit/test_fake_pymongo.py b/result_collection_api/tests/unit/test_fake_pymongo.py index 228fed7..6920fca 100644 --- a/result_collection_api/tests/unit/test_fake_pymongo.py +++ b/result_collection_api/tests/unit/test_fake_pymongo.py @@ -10,6 +10,7 @@ class MyTest(AsyncHTTPTestCase): def setUp(self): super(MyTest, self).setUp() self.db = fake_pymongo + self.addCleanup(self._clear) self.io_loop.run_sync(self.fixture_setup) def get_app(self): @@ -26,6 +27,7 @@ class MyTest(AsyncHTTPTestCase): def test_find_one(self): user = yield self.db.pods.find_one({'name': 'test1'}) self.assertEqual(user, self.test1) + self.db.pods.remove() @gen_test def test_find(self): @@ -48,5 +50,19 @@ class MyTest(AsyncHTTPTestCase): user = yield self.db.pods.find_one({'_id': '1'}) self.assertIsNone(user) + @gen_test + def test_insert_check_keys(self): + yield self.db.pods.insert({'_id': '1', 'name': 'test1'}, + check_keys=False) + cursor = self.db.pods.find({'_id': '1'}) + names = [] + while (yield cursor.fetch_next): + ob = cursor.next_object() + names.append(ob.get('name')) + self.assertItemsEqual(names, ['test1', 'test1']) + + def _clear(self): + self.db.pods.clear() + if __name__ == '__main__': unittest.main() |