From 72de1829c79a377e0ae1d69f0ebf6af495c06b08 Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Wed, 15 Jun 2016 09:49:35 +0800 Subject: support keys start with '$' or contain '.' in testAPI set check_keys=False in insert and update db fix update and insert stub in fake_pymongo.py add unittest for check_keys in test_fake_pymongo.py JIRA: FUNCTEST-313 Change-Id: I4051ec4a1c70996c87167643f6ea19993f5b0811 Signed-off-by: SerenaFeng --- .../result_collection_api/opnfv_testapi/resources/handlers.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'utils/test/result_collection_api/opnfv_testapi/resources') diff --git a/utils/test/result_collection_api/opnfv_testapi/resources/handlers.py b/utils/test/result_collection_api/opnfv_testapi/resources/handlers.py index cc4a4c357..873701103 100644 --- a/utils/test/result_collection_api/opnfv_testapi/resources/handlers.py +++ b/utils/test/result_collection_api/opnfv_testapi/resources/handlers.py @@ -98,7 +98,8 @@ class GenericApiHandler(RequestHandler): if self.table != 'results': data.creation_date = datetime.now() - _id = yield self._eval_db(self.table, 'insert', data.format()) + _id = yield self._eval_db(self.table, 'insert', data.format(), + check_keys=False) if 'name' in self.json_args: resource = data.name else: @@ -174,7 +175,8 @@ class GenericApiHandler(RequestHandler): edit_request.update(self._update_requests(data)) """ Updating the DB """ - yield self._eval_db(self.table, 'update', query, edit_request) + yield self._eval_db(self.table, 'update', query, edit_request, + check_keys=False) edit_request['_id'] = str(data._id) self.finish_request(edit_request) @@ -215,8 +217,8 @@ class GenericApiHandler(RequestHandler): query[key] = new return equal, query - def _eval_db(self, table, method, *args): - return eval('self.db.%s.%s(*args)' % (table, method)) + def _eval_db(self, table, method, *args, **kwargs): + return eval('self.db.%s.%s(*args, **kwargs)' % (table, method)) def _eval_db_find_one(self, query, table=None): if table is None: -- cgit 1.2.3-korg