diff options
-rw-r--r-- | testapi/opnfv_testapi/common/check.py | 1 | ||||
-rw-r--r-- | testapi/opnfv_testapi/handlers/pod_handlers.py | 16 | ||||
-rw-r--r-- | testapi/opnfv_testapi/tests/unit/fake_pymongo.py | 1 |
3 files changed, 15 insertions, 3 deletions
diff --git a/testapi/opnfv_testapi/common/check.py b/testapi/opnfv_testapi/common/check.py index db28e44..8a76f17 100644 --- a/testapi/opnfv_testapi/common/check.py +++ b/testapi/opnfv_testapi/common/check.py @@ -139,7 +139,6 @@ def new_not_exists(xstep): if query_data.get('name') is not None: query_data['name'] = re.compile('\\b' + query_data.get('name') + '\\b', re.IGNORECASE) to_data = yield dbapi.db_find_one(self.table, query_data) - print to_data if to_data: raises.Forbidden(message.exist(self.table, query())) ret = yield gen.coroutine(xstep)(self, *args, **kwargs) diff --git a/testapi/opnfv_testapi/handlers/pod_handlers.py b/testapi/opnfv_testapi/handlers/pod_handlers.py index 9e52ca0..06a8b17 100644 --- a/testapi/opnfv_testapi/handlers/pod_handlers.py +++ b/testapi/opnfv_testapi/handlers/pod_handlers.py @@ -6,6 +6,8 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import re + from opnfv_testapi.handlers import base_handlers from opnfv_testapi.models import pod_models from opnfv_testapi.tornado_swagger import swagger @@ -17,6 +19,14 @@ class GenericPodHandler(base_handlers.GenericApiHandler): self.table = 'pods' self.table_cls = pod_models.Pod + def set_query(self): + query = dict() + for k in self.request.query_arguments.keys(): + v = self.get_query_argument(k) + if k == 'name': + query['name'] = re.compile(v, re.IGNORECASE) + return query + class PodCLHandler(GenericPodHandler): @swagger.operation(nickname='listAllPods') @@ -25,8 +35,12 @@ class PodCLHandler(GenericPodHandler): @description: list all pods @return 200: list all pods, empty list is no pod exist @rtype: L{Pods} + @param name: pod name + @type name: L{string} + @in name: query + @required name: False """ - self._list() + self._list(query=self.set_query()) @swagger.operation(nickname='createPod') def post(self): diff --git a/testapi/opnfv_testapi/tests/unit/fake_pymongo.py b/testapi/opnfv_testapi/tests/unit/fake_pymongo.py index c44a92c..39b7e6a 100644 --- a/testapi/opnfv_testapi/tests/unit/fake_pymongo.py +++ b/testapi/opnfv_testapi/tests/unit/fake_pymongo.py @@ -213,7 +213,6 @@ class MemDb(object): def _aggregate(self, *args, **kwargs): res = self.contents - print args for arg in args[0]: for k, v in arg.iteritems(): if k == '$match': |