summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/common
diff options
context:
space:
mode:
authorthuva4 <tharma.thuva@gmail.com>2017-09-07 19:03:57 +0530
committerthuva4 <tharma.thuva@gmail.com>2017-09-11 14:48:55 +0530
commitb1ef7b7f6f892763da375a72c0a4c1d9f4790db3 (patch)
treee56857badc00dde6118b9f1ab6c69112b63b6066 /testapi/opnfv_testapi/common
parentb3580028292d2927564020e8143bc1f659ef0ab3 (diff)
add case-insensitive for find pods query
Now user can't create the pods with the same name. Just like "Demo" , "deMo" and "demo" Add unit test for case-insensitive query Change-Id: Ifddc7b70a38d8504e5fe105fa5cc1a77bf0e39a9 Signed-off-by: thuva4 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/opnfv_testapi/common')
-rw-r--r--testapi/opnfv_testapi/common/check.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/testapi/opnfv_testapi/common/check.py b/testapi/opnfv_testapi/common/check.py
index 24ba876..acd3317 100644
--- a/testapi/opnfv_testapi/common/check.py
+++ b/testapi/opnfv_testapi/common/check.py
@@ -7,6 +7,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import functools
+import re
from tornado import gen
from tornado import web
@@ -92,7 +93,12 @@ def new_not_exists(xstep):
def wrap(self, *args, **kwargs):
query = kwargs.get('query')
if query:
- to_data = yield dbapi.db_find_one(self.table, query())
+ query_data = query()
+ if self.table == 'pods':
+ if query_data.get('name') is not None:
+ query_data['name'] = re.compile(query_data.get('name'),
+ re.IGNORECASE)
+ to_data = yield dbapi.db_find_one(self.table, query_data)
if to_data:
raises.Forbidden(message.exist(self.table, query()))
ret = yield gen.coroutine(xstep)(self, *args, **kwargs)