diff options
author | 2017-07-19 13:29:53 +0800 | |
---|---|---|
committer | 2017-07-19 13:29:53 +0800 | |
commit | db986d8524d8befa075b213c81168f7102c78b56 (patch) | |
tree | 39434e566a244124e9935646f05a2ae526927a6d /utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py | |
parent | f4077629308e7374d9e92923af996cf7bf79678c (diff) |
bugfix: query doesn't work well with period=1
when querying by date, if $lt is not provided,
the empty/None/null/'' results will also be returned,
the patch aims to fix this issue by adding
$lt = datetime.now() if not provided
JIRA: RELENG-212
Change-Id: Ida1e7d386a88d4ab640441df161c1fe134593f82
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py')
-rw-r--r-- | utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py b/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py index adaf6f7c3..04785d2b8 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py +++ b/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py @@ -119,10 +119,14 @@ class MemDb(object): @staticmethod def _compare_date(spec, value): + gte = True + lt = False for k, v in spec.iteritems(): - if k == '$gte' and value >= v: - return True - return False + if k == '$gte' and value < v: + gte = False + elif k == '$lt' and value < v: + lt = True + return gte and lt def _in(self, content, *args): if self.name == 'scenarios': |