diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-05-31 20:44:03 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-05-31 20:45:57 +0800 |
commit | 94fbad49d3b35bd9c997e1904d265b7b25d81a0f (patch) | |
tree | 732c2c6a13f4669dade017b10479710209a4b76e /utils/test | |
parent | 16dff1bf982d842bcdd717ff8c69627f1cdbdb52 (diff) |
bugfix: query results failed due to wrong using type of trust_indicator
trust_indicator must be int/long/float rather than string
JIRA: FUNCTEST-280
Change-Id: I2e2b292f9181fd28896bfe1e3b86ec3976b65016
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils/test')
3 files changed, 13 insertions, 6 deletions
diff --git a/utils/test/result_collection_api/resources/result_handlers.py b/utils/test/result_collection_api/resources/result_handlers.py index e7fce47df..1d52235f6 100644 --- a/utils/test/result_collection_api/resources/result_handlers.py +++ b/utils/test/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/utils/test/result_collection_api/resources/result_models.py b/utils/test/result_collection_api/resources/result_models.py index 27c354220..40d21c331 100644 --- a/utils/test/result_collection_api/resources/result_models.py +++ b/utils/test/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/utils/test/result_collection_api/tests/unit/test_result.py b/utils/test/result_collection_api/tests/unit/test_result.py index 7829d7c6a..7b1f97654 100644 --- a/utils/test/result_collection_api/tests/unit/test_result.py +++ b/utils/test/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): |