diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-06-01 15:36:17 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-06-01 16:21:46 +0800 |
commit | a55651eb098da2e1aa90c93294a59857711b48c1 (patch) | |
tree | 654e3adace1e4ae1690d9612c5d7b1704a607a5e /utils/test/result_collection_api/tests/unit/test_fake_pymongo.py | |
parent | e0d66ea067ea59724c1dc300abe8052d4dcf88d1 (diff) |
project-ize testAPI
JIRA: FUNCTEST-284
Change-Id: I219e934bb11f50de84df2aa0345ecc7885223491
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils/test/result_collection_api/tests/unit/test_fake_pymongo.py')
-rw-r--r-- | utils/test/result_collection_api/tests/unit/test_fake_pymongo.py | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/utils/test/result_collection_api/tests/unit/test_fake_pymongo.py b/utils/test/result_collection_api/tests/unit/test_fake_pymongo.py deleted file mode 100644 index 6920fcad8..000000000 --- a/utils/test/result_collection_api/tests/unit/test_fake_pymongo.py +++ /dev/null @@ -1,68 +0,0 @@ -import unittest -from tornado.web import Application -from tornado import gen -from tornado.testing import AsyncHTTPTestCase, gen_test - -import fake_pymongo - - -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): - return Application() - - @gen.coroutine - def fixture_setup(self): - self.test1 = {'_id': '1', 'name': 'test1'} - self.test2 = {'name': 'test2'} - yield self.db.pods.insert({'_id': '1', 'name': 'test1'}) - yield self.db.pods.insert({'name': 'test2'}) - - @gen_test - 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): - cursor = self.db.pods.find() - names = [] - while (yield cursor.fetch_next): - ob = cursor.next_object() - names.append(ob.get('name')) - self.assertItemsEqual(names, ['test1', 'test2']) - - @gen_test - def test_update(self): - yield self.db.pods.update({'_id': '1'}, {'name': 'new_test1'}) - user = yield self.db.pods.find_one({'_id': '1'}) - self.assertEqual(user.get('name', None), 'new_test1') - - @gen_test - def test_remove(self): - yield self.db.pods.remove({'_id': '1'}) - 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() |