diff options
Diffstat (limited to 'utils')
7 files changed, 43 insertions, 39 deletions
diff --git a/utils/test/result_collection_api/resources/pod_models.py b/utils/test/result_collection_api/resources/pod_models.py index cc98c90ce..0ccb66162 100644 --- a/utils/test/result_collection_api/resources/pod_models.py +++ b/utils/test/result_collection_api/resources/pod_models.py @@ -62,10 +62,11 @@ class Pod(PodCreateRequest): @swagger.model() class Pods(object): """ + @property pods: @ptype pods: C{list} of L{Pod} """ - def __init__(self, pods=list()): - self.pods = pods + def __init__(self): + self.pods = list() @staticmethod def from_dict(res_dict): diff --git a/utils/test/result_collection_api/resources/project_models.py b/utils/test/result_collection_api/resources/project_models.py index a1592c31d..1dc0c40e5 100644 --- a/utils/test/result_collection_api/resources/project_models.py +++ b/utils/test/result_collection_api/resources/project_models.py @@ -71,10 +71,11 @@ class Project(object): @swagger.model() class Projects(object): """ + @property projects: @ptype projects: C{list} of L{Project} """ - def __init__(self, projects=list()): - self.projects = projects + def __init__(self): + self.projects = list() @staticmethod def from_dict(res_dict): diff --git a/utils/test/result_collection_api/resources/result_models.py b/utils/test/result_collection_api/resources/result_models.py index 7faac16d4..27c354220 100644 --- a/utils/test/result_collection_api/resources/result_models.py +++ b/utils/test/result_collection_api/resources/result_models.py @@ -48,20 +48,24 @@ class ResultCreateRequest(object): @swagger.model() class TestResult(object): - def __init__(self): - self._id = None - self.case_name = None - self.project_name = None - self.pod_name = None - self.installer = None - self.version = None - self.start_date = None - self.stop_date = None - self.details = None - self.build_tag = None - self.scenario = None - self.criteria = None - self.trust_indicator = None + 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, + build_tag=None, scenario=None, criteria=None, + trust_indicator=None): + self._id = _id + self.case_name = case_name + self.project_name = project_name + self.pod_name = pod_name + self.installer = installer + self.version = version + self.start_date = start_date + self.stop_date = stop_date + self.details = details + self.build_tag = build_tag + self.scenario = scenario + self.criteria = criteria + self.trust_indicator = trust_indicator @staticmethod def from_dict(a_dict): @@ -137,10 +141,11 @@ class TestResult(object): @swagger.model() class TestResults(object): """ - @ptype testcases: C{list} of L{TestResult} + @property results: + @ptype results: C{list} of L{TestResult} """ - def __init__(self, results=list()): - self.results = results + def __init__(self): + self.results = list() @staticmethod def from_dict(a_dict): diff --git a/utils/test/result_collection_api/resources/testcase_models.py b/utils/test/result_collection_api/resources/testcase_models.py index 90b3f75e9..a69f2f751 100644 --- a/utils/test/result_collection_api/resources/testcase_models.py +++ b/utils/test/result_collection_api/resources/testcase_models.py @@ -82,10 +82,11 @@ class Testcase(object): @swagger.model() class Testcases(object): """ + @property testcases: @ptype testcases: C{list} of L{Testcase} """ - def __init__(self, testcases=list()): - self.testcases = testcases + def __init__(self): + self.testcases = list() @staticmethod def from_dict(res_dict): diff --git a/utils/test/result_collection_api/tests/unit/fake_pymongo.py b/utils/test/result_collection_api/tests/unit/fake_pymongo.py index 3494280fa..95c7371dc 100644 --- a/utils/test/result_collection_api/tests/unit/fake_pymongo.py +++ b/utils/test/result_collection_api/tests/unit/fake_pymongo.py @@ -5,6 +5,12 @@ from concurrent.futures import ThreadPoolExecutor __author__ = 'serena' +def thread_execute(method, *args, **kwargs): + with ThreadPoolExecutor(max_workers=2) as executor: + result = executor.submit(method, *args, **kwargs) + return result + + class MemCursor(object): def __init__(self, collection): self.collection = collection @@ -15,9 +21,7 @@ class MemCursor(object): @property def fetch_next(self): - with ThreadPoolExecutor(max_workers=2) as executor: - result = executor.submit(self._is_next_exist) - return result + return thread_execute(self._is_next_exist) def next_object(self): self.count -= 1 @@ -41,9 +45,7 @@ class MemDb(object): return None def find_one(self, spec_or_id=None, *args): - with ThreadPoolExecutor(max_workers=2) as executor: - result = executor.submit(self._find_one, spec_or_id, *args) - return result + return thread_execute(self._find_one, spec_or_id, *args) def _insert(self, doc_or_docs, check_keys=True): @@ -69,9 +71,7 @@ class MemDb(object): return ids def insert(self, doc_or_docs, check_keys=True): - with ThreadPoolExecutor(max_workers=2) as executor: - result = executor.submit(self._insert, doc_or_docs, check_keys) - return result + return thread_execute(self._insert, doc_or_docs, check_keys) @staticmethod def _in(content, *args): @@ -105,9 +105,7 @@ class MemDb(object): return updated def update(self, spec, document): - with ThreadPoolExecutor(max_workers=2) as executor: - result = executor.submit(self._update, spec, document) - return result + return thread_execute(self._update, spec, document) def _remove(self, spec_or_id=None): if spec_or_id is None: @@ -122,9 +120,7 @@ class MemDb(object): return False def remove(self, spec_or_id=None): - with ThreadPoolExecutor(max_workers=2) as executor: - result = executor.submit(self._remove, spec_or_id) - return result + return thread_execute(self._remove, spec_or_id) def clear(self): self._remove() diff --git a/utils/test/result_collection_api/tests/unit/test_dashboard.py b/utils/test/result_collection_api/tests/unit/test_dashboard.py index 3e713332c..5c3f92492 100644 --- a/utils/test/result_collection_api/tests/unit/test_dashboard.py +++ b/utils/test/result_collection_api/tests/unit/test_dashboard.py @@ -44,7 +44,6 @@ class TestDashboardQuery(TestDashboardBase): def test_success(self): code, body = self.query(self._set_query()) self.assertEqual(code, HTTP_OK) - print(body) self.assertIn('{"description": "vPing results for Dashboard"}', body) def test_caseIsStatus(self): 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 f08ccea83..7829d7c6a 100644 --- a/utils/test/result_collection_api/tests/unit/test_result.py +++ b/utils/test/result_collection_api/tests/unit/test_result.py @@ -234,6 +234,7 @@ class TestResultGet(TestResultBase): self.assertEqual(0, len(body.results)) else: for result in body.results: + self.assertEqual(1, len(body.results)) self.assert_res(code, result) def _set_query(self, *args): |