Merge "Enable parser project"
[releng.git] / utils / test / testapi / opnfv_testapi / tests / unit / fake_pymongo.py
index 04785d2..c44a92c 100644 (file)
@@ -6,9 +6,12 @@
 # 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
 from concurrent.futures import ThreadPoolExecutor
-from operator import itemgetter
 
 
 def thread_execute(method, *args, **kwargs):
@@ -189,9 +192,13 @@ class MemDb(object):
                 elif k == 'trust_indicator.current':
                     if content.get('trust_indicator').get('current') != v:
                         return False
-                elif 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):
@@ -282,3 +288,4 @@ testcases = MemDb('testcases')
 results = MemDb('results')
 scenarios = MemDb('scenarios')
 tokens = MemDb('tokens')
+users = MemDb('users')