diff options
author | 2016-05-31 14:42:08 +0000 | |
---|---|---|
committer | 2016-05-31 14:42:08 +0000 | |
commit | fa69670740d165b896eebd9efaa071482f0b8fd8 (patch) | |
tree | 3fd3b68731bae2ab5daeda4dc7305e0399d0735d | |
parent | b138bbe853a26c63ac978824648429321f92868c (diff) | |
parent | c6ace67b6c587663dd83b5aa6afb126380e16678 (diff) |
Merge "bugfix: query results failed due to wrong using type of trust_indicator"
-rw-r--r-- | result_collection_api/resources/result_handlers.py | 4 | ||||
-rw-r--r-- | result_collection_api/resources/result_models.py | 4 | ||||
-rw-r--r-- | result_collection_api/tests/unit/test_result.py | 11 |
3 files changed, 13 insertions, 6 deletions
diff --git a/result_collection_api/resources/result_handlers.py b/result_collection_api/resources/result_handlers.py index e7fce47..1d52235 100644 --- a/result_collection_api/resources/result_handlers.py +++ b/result_collection_api/resources/result_handlers.py @@ -32,6 +32,8 @@ class GenericResultHandler(GenericApiHandler): period = datetime.now() - timedelta(days=v) obj = {"$gte": str(period)} query['creation_date'] = obj + elif k == 'trust_indicator': + query[k] = float(v) else: query[k] = v return query @@ -98,7 +100,7 @@ class ResultsCLHandler(GenericResultHandler): @type period: L{string} @in period: query @required period: False - @param trust_indicator: must be integer + @param trust_indicator: must be int/long/float @type trust_indicator: L{string} @in trust_indicator: query @required trust_indicator: False diff --git a/result_collection_api/resources/result_models.py b/result_collection_api/resources/result_models.py index 27c3542..40d21c3 100644 --- a/result_collection_api/resources/result_models.py +++ b/result_collection_api/resources/result_models.py @@ -48,6 +48,10 @@ class ResultCreateRequest(object): @swagger.model() class TestResult(object): + """ + @property trust_indicator: must be int/long/float + @ptype trust_indicator: L{float} + """ def __init__(self, _id=None, case_name=None, project_name=None, pod_name=None, installer=None, version=None, start_date=None, stop_date=None, details=None, diff --git a/result_collection_api/tests/unit/test_result.py b/result_collection_api/tests/unit/test_result.py index 7829d7c..7b1f976 100644 --- a/result_collection_api/tests/unit/test_result.py +++ b/result_collection_api/tests/unit/test_result.py @@ -79,9 +79,10 @@ class TestResultBase(TestBase): self.req_testcase, self.project) - def assert_res(self, code, result): + def assert_res(self, code, result, req=None): self.assertEqual(code, HTTP_OK) - req = self.req_d + if req is None: + req = self.req_d self.assertEqual(result.pod_name, req.pod_name) self.assertEqual(result.project_name, req.project_name) self.assertEqual(result.case_name, req.case_name) @@ -96,8 +97,8 @@ class TestResultBase(TestBase): self.assertEqual(result.scenario, req.scenario) self.assertEqual(result.criteria, req.criteria) self.assertEqual(result.trust_indicator, req.trust_indicator) - self.assertIsNotNone(result.start_date) - self.assertIsNotNone(result.stop_date) + self.assertEqual(result.start_date, req.start_date) + self.assertEqual(result.stop_date, req.stop_date) self.assertIsNotNone(result._id) @@ -233,8 +234,8 @@ class TestResultGet(TestResultBase): self.assertEqual(code, HTTP_OK) self.assertEqual(0, len(body.results)) else: + self.assertEqual(1, len(body.results)) for result in body.results: - self.assertEqual(1, len(body.results)) self.assert_res(code, result) def _set_query(self, *args): |