summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
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/tests/unit/fake_pymongo.py
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/tests/unit/fake_pymongo.py')
-rw-r--r--testapi/opnfv_testapi/tests/unit/fake_pymongo.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/testapi/opnfv_testapi/tests/unit/fake_pymongo.py b/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
index 0ca83df..3320a86 100644
--- a/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
+++ b/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
@@ -6,6 +6,8 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import re
+
from operator import itemgetter
from bson.objectid import ObjectId
@@ -190,8 +192,13 @@ class MemDb(object):
elif k == 'trust_indicator.current':
if content.get('trust_indicator').get('current') != v:
return False
- elif not isinstance(v, dict) and content.get(k, None) != v:
- return False
+ elif not isinstance(v, dict):
+ if isinstance(v, re._pattern_type):
+ if v.match(content.get(k, None)) is None:
+ return False
+ else:
+ if content.get(k, None) != v:
+ return False
return True
def _find(self, *args):
@@ -199,7 +206,6 @@ class MemDb(object):
for content in self.contents:
if self._in(content, *args):
res.append(content)
-
return res
def find(self, *args):