summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/common
diff options
context:
space:
mode:
authorSerena Feng <feng.xiaowei@zte.com.cn>2018-01-04 05:59:33 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-01-04 05:59:33 +0000
commit28edfefe25420964a8ca961f45f3b8860f60b6d6 (patch)
tree8d2d91e20784dadb46d07384fda55f3ab100eff5 /testapi/opnfv_testapi/common
parentc72bebf41dbd08facb7398fa94680d812ea38a62 (diff)
parentf505dab1f5f26154619ec5c30cabbd8efaad173e (diff)
Merge "leverage query_by_name decorator to simplify name querying"
Diffstat (limited to 'testapi/opnfv_testapi/common')
-rw-r--r--testapi/opnfv_testapi/common/check.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/testapi/opnfv_testapi/common/check.py b/testapi/opnfv_testapi/common/check.py
index 5dfbc75..333871d 100644
--- a/testapi/opnfv_testapi/common/check.py
+++ b/testapi/opnfv_testapi/common/check.py
@@ -158,3 +158,17 @@ def updated_one_not_exist(xstep):
ret = yield gen.coroutine(xstep)(self, data, *args, **kwargs)
raise gen.Return(ret)
return wrap
+
+
+def query_by_name(xstep):
+ @functools.wraps(xstep)
+ def wrap(self, *args, **kwargs):
+ if 'name' in self.request.query_arguments.keys():
+ query = kwargs.get('query', {})
+ query.update({'name': re.compile(self.get_query_argument('name'), re.IGNORECASE)})
+ kwargs.update({'query': query})
+
+ ret = yield gen.coroutine(xstep)(self, *args, **kwargs)
+ raise gen.Return(ret)
+
+ return wrap