diff options
author | Morgan Richomme <morgan.richomme@orange.com> | 2016-05-25 09:50:08 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2016-05-25 09:50:08 +0000 |
commit | f204fed9d8519f994b085a1139f036bc40fcddbc (patch) | |
tree | 9e90094bbb1760363d666b8ad1c52b99ad730fab /result_collection_api/tests/unit/test_fake_pymongo.py | |
parent | 02825c3c21fc5c46d4952c1410f96e3836b50b61 (diff) | |
parent | 0c898e11323cf4e5baabecb55d8be2ff2268690d (diff) |
Merge "add test result/dashboard related unittests in testAPI and refactor its response"
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() |