diff options
Diffstat (limited to 'utils/test/testapi')
12 files changed, 140 insertions, 382 deletions
diff --git a/utils/test/testapi/install.sh b/utils/test/testapi/install.sh index 43229eabb..c55691aed 100755 --- a/utils/test/testapi/install.sh +++ b/utils/test/testapi/install.sh @@ -10,9 +10,17 @@ usage: where: -h|--help show this help text" -if [[ $(whoami) != "root" ]]; then - echo "Error: This script must be run as root!" - exit 1 +# Ref :- https://openstack.nimeyo.com/87286/openstack-packaging-all-definition-data-files-config-setup + +if [ -z "$VIRTUAL_ENV" ]; +then + if [[ $(whoami) != "root" ]]; + then + echo "Error: This script must be run as root!" + exit 1 + fi +else + sed -i -e 's#/etc/opnfv_testapi =#etc/opnfv_testapi =#g' setup.cfg fi cp -fr 3rd_party/static opnfv_testapi/tornado_swagger diff --git a/utils/test/testapi/opnfv_testapi/resources/handlers.py b/utils/test/testapi/opnfv_testapi/resources/handlers.py index 5059f5d77..f1ad15e97 100644 --- a/utils/test/testapi/opnfv_testapi/resources/handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/handlers.py @@ -227,7 +227,7 @@ class GenericApiHandler(RequestHandler): class VersionHandler(GenericApiHandler): - @swagger.operation(nickname='list') + @swagger.operation(nickname='List all versions') def get(self): """ @description: list all supported versions diff --git a/utils/test/testapi/opnfv_testapi/resources/models.py b/utils/test/testapi/opnfv_testapi/resources/models.py index e79308b53..f518c97a0 100644 --- a/utils/test/testapi/opnfv_testapi/resources/models.py +++ b/utils/test/testapi/opnfv_testapi/resources/models.py @@ -12,60 +12,87 @@ # feng.xiaowei@zte.com.cn add CreateResponse 5-19-2016
# feng.xiaowei@zte.com.cn mv TestCase to testcase_models.py 5-20-2016
# feng.xiaowei@zte.com.cn mv TestResut to result_models.py 5-23-2016
+# feng.xiaowei@zte.com.cn add ModelBase 12-20-2016
##############################################################################
+import copy
+
from opnfv_testapi.tornado_swagger import swagger
-@swagger.model()
-class CreateResponse(object):
- def __init__(self, href=''):
- self.href = href
+class ModelBase(object):
+
+ def _format(self, excludes):
+ new_obj = copy.deepcopy(self)
+ dicts = new_obj.__dict__
+ for k in dicts.keys():
+ if k in excludes:
+ del dicts[k]
+ elif dicts[k]:
+ if hasattr(dicts[k], 'format'):
+ dicts[k] = dicts[k].format()
+ elif isinstance(dicts[k], list):
+ hs = list()
+ [hs.append(h.format() if hasattr(h, 'format') else str(h))
+ for h in dicts[k]]
+ dicts[k] = hs
+ elif not isinstance(dicts[k], (str, int, float, dict)):
+ dicts[k] = str(dicts[k])
+ return dicts
+
+ def format(self):
+ return self._format(['_id'])
+
+ def format_http(self):
+ return self._format([])
@staticmethod
- def from_dict(res_dict):
- if res_dict is None:
+ def attr_parser():
+ return {}
+
+ @classmethod
+ def from_dict(cls, a_dict):
+ if a_dict is None:
return None
- res = CreateResponse()
- res.href = res_dict.get('href')
- return res
+ attr_parser = cls.attr_parser()
+ t = cls()
+ for k, v in a_dict.iteritems():
+ value = v
+ if isinstance(v, dict) and k in attr_parser:
+ value = attr_parser[k].from_dict(v)
+ elif isinstance(v, list) and k in attr_parser:
+ value = []
+ for item in v:
+ value.append(attr_parser[k].from_dict(item))
- def format(self):
- return {'href': self.href}
+ t.__setattr__(k, value)
+
+ return t
@swagger.model()
-class Versions(object):
+class CreateResponse(ModelBase):
+ def __init__(self, href=''):
+ self.href = href
+
+
+@swagger.model()
+class Versions(ModelBase):
"""
@property versions:
@ptype versions: C{list} of L{Version}
"""
+
def __init__(self):
self.versions = list()
@staticmethod
- def from_dict(res_dict):
- if res_dict is None:
- return None
-
- res = Versions()
- for version in res_dict.get('versions'):
- res.versions.append(Version.from_dict(version))
- return res
+ def attr_parser():
+ return {'versions': Version}
@swagger.model()
-class Version(object):
+class Version(ModelBase):
def __init__(self, version=None, description=None):
self.version = version
self.description = description
-
- @staticmethod
- def from_dict(a_dict):
- if a_dict is None:
- return None
-
- ver = Version()
- ver.version = a_dict.get('version')
- ver.description = str(a_dict.get('description'))
- return ver
diff --git a/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py b/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py index 8f44439e7..631d4a91d 100644 --- a/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py @@ -20,7 +20,7 @@ class GenericPodHandler(GenericApiHandler): class PodCLHandler(GenericPodHandler): - @swagger.operation(nickname='list-all') + @swagger.operation(nickname='List all Pods') def get(self): """ @description: list all pods @@ -29,7 +29,7 @@ class PodCLHandler(GenericPodHandler): """ self._list() - @swagger.operation(nickname='create') + @swagger.operation(nickname='Create a Pod') def post(self): """ @description: create a pod @@ -54,7 +54,7 @@ class PodCLHandler(GenericPodHandler): class PodGURHandler(GenericPodHandler): - @swagger.operation(nickname='get-one') + @swagger.operation(nickname='Get a Pod by pod_name') def get(self, pod_name): """ @description: get a single pod by pod_name diff --git a/utils/test/testapi/opnfv_testapi/resources/pod_models.py b/utils/test/testapi/opnfv_testapi/resources/pod_models.py index 7231806f6..26a9e6788 100644 --- a/utils/test/testapi/opnfv_testapi/resources/pod_models.py +++ b/utils/test/testapi/opnfv_testapi/resources/pod_models.py @@ -6,8 +6,10 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import models from opnfv_testapi.tornado_swagger import swagger + # name: name of the POD e.g. zte-1 # mode: metal or virtual # details: any detail @@ -15,58 +17,29 @@ from opnfv_testapi.tornado_swagger import swagger @swagger.model() -class PodCreateRequest(object): +class PodCreateRequest(models.ModelBase): def __init__(self, name, mode='', details='', role=""): self.name = name self.mode = mode self.details = details self.role = role - def format(self): - return { - "name": self.name, - "mode": self.mode, - "details": self.details, - "role": self.role, - } - @swagger.model() -class Pod(PodCreateRequest): +class Pod(models.ModelBase): def __init__(self, name='', mode='', details='', role="", _id='', create_date=''): - super(Pod, self).__init__(name, mode, details, role) + self.name = name + self.mode = mode + self.details = details + self.role = role self._id = _id self.creation_date = create_date - @staticmethod - def from_dict(pod_dict): - if pod_dict is None: - return None - - p = Pod() - p._id = pod_dict.get('_id') - p.creation_date = str(pod_dict.get('creation_date')) - p.name = pod_dict.get('name') - p.mode = pod_dict.get('mode') - p.details = pod_dict.get('details') - p.role = pod_dict.get('role') - return p - - def format(self): - f = super(Pod, self).format() - f['creation_date'] = str(self.creation_date) - return f - - def format_http(self): - f = self.format() - f['_id'] = str(self._id) - return f - @swagger.model() -class Pods(object): +class Pods(models.ModelBase): """ @property pods: @ptype pods: C{list} of L{Pod} @@ -75,11 +48,5 @@ class Pods(object): self.pods = list() @staticmethod - def from_dict(res_dict): - if res_dict is None: - return None - - res = Pods() - for pod in res_dict.get('pods'): - res.pods.append(Pod.from_dict(pod)) - return res + def attr_parser(): + return {'pods': Pod} diff --git a/utils/test/testapi/opnfv_testapi/resources/project_handlers.py b/utils/test/testapi/opnfv_testapi/resources/project_handlers.py index 1e9a97230..9cf698623 100644 --- a/utils/test/testapi/opnfv_testapi/resources/project_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/project_handlers.py @@ -22,7 +22,7 @@ class GenericProjectHandler(GenericApiHandler): class ProjectCLHandler(GenericProjectHandler): - @swagger.operation(nickname="list-all") + @swagger.operation(nickname="List all Projects") def get(self): """ @description: list all projects @@ -31,7 +31,7 @@ class ProjectCLHandler(GenericProjectHandler): """ self._list() - @swagger.operation(nickname="create") + @swagger.operation(nickname="Create a Project") def post(self): """ @description: create a project @@ -56,7 +56,7 @@ class ProjectCLHandler(GenericProjectHandler): class ProjectGURHandler(GenericProjectHandler): - @swagger.operation(nickname='get-one') + @swagger.operation(nickname='Get a Project by project_name') def get(self, project_name): """ @description: get a single project by project_name @@ -66,7 +66,7 @@ class ProjectGURHandler(GenericProjectHandler): """ self._get_one({'name': project_name}) - @swagger.operation(nickname="update") + @swagger.operation(nickname="Update a Project by project_name") def put(self, project_name): """ @description: update a single project by project_name @@ -82,7 +82,7 @@ class ProjectGURHandler(GenericProjectHandler): db_keys = ['name'] self._update(query, db_keys) - @swagger.operation(nickname='delete') + @swagger.operation(nickname='Delete a Project by project_name') def delete(self, project_name): """ @description: delete a project by project_name diff --git a/utils/test/testapi/opnfv_testapi/resources/project_models.py b/utils/test/testapi/opnfv_testapi/resources/project_models.py index f70630cda..f7323c1c4 100644 --- a/utils/test/testapi/opnfv_testapi/resources/project_models.py +++ b/utils/test/testapi/opnfv_testapi/resources/project_models.py @@ -6,37 +6,26 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import models from opnfv_testapi.tornado_swagger import swagger @swagger.model() -class ProjectCreateRequest(object): +class ProjectCreateRequest(models.ModelBase): def __init__(self, name, description=''): self.name = name self.description = description - def format(self): - return { - "name": self.name, - "description": self.description, - } - @swagger.model() -class ProjectUpdateRequest(object): +class ProjectUpdateRequest(models.ModelBase): def __init__(self, name='', description=''): self.name = name self.description = description - def format(self): - return { - "name": self.name, - "description": self.description, - } - @swagger.model() -class Project(object): +class Project(models.ModelBase): def __init__(self, name=None, _id=None, description=None, create_date=None): self._id = _id @@ -44,38 +33,9 @@ class Project(object): self.description = description self.creation_date = create_date - @staticmethod - def from_dict(res_dict): - - if res_dict is None: - return None - - t = Project() - t._id = res_dict.get('_id') - t.creation_date = res_dict.get('creation_date') - t.name = res_dict.get('name') - t.description = res_dict.get('description') - - return t - - def format(self): - return { - "name": self.name, - "description": self.description, - "creation_date": str(self.creation_date) - } - - def format_http(self): - return { - "_id": str(self._id), - "name": self.name, - "description": self.description, - "creation_date": str(self.creation_date), - } - @swagger.model() -class Projects(object): +class Projects(models.ModelBase): """ @property projects: @ptype projects: C{list} of L{Project} @@ -84,11 +44,5 @@ class Projects(object): self.projects = list() @staticmethod - def from_dict(res_dict): - if res_dict is None: - return None - - res = Projects() - for project in res_dict.get('projects'): - res.projects.append(Project.from_dict(project)) - return res + def attr_parser(): + return {'projects': Project} diff --git a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py index 400b84ac1..fe13c09b7 100644 --- a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py @@ -52,7 +52,7 @@ class GenericResultHandler(GenericApiHandler): class ResultsCLHandler(GenericResultHandler): - @swagger.operation(nickname="list-all") + @swagger.operation(nickname="List all Test Results") def get(self): """ @description: Retrieve result(s) for a test project @@ -127,7 +127,7 @@ class ResultsCLHandler(GenericResultHandler): self._list(self.set_query(), sort=[('start_date', -1)], last=last) - @swagger.operation(nickname="create") + @swagger.operation(nickname="Create a Test Result") def post(self): """ @description: create a test result @@ -169,7 +169,7 @@ class ResultsCLHandler(GenericResultHandler): class ResultsGURHandler(GenericResultHandler): - @swagger.operation(nickname='get-one') + @swagger.operation(nickname='Get a Test Result by result_id') def get(self, result_id): """ @description: get a single result by result_id @@ -181,7 +181,7 @@ class ResultsGURHandler(GenericResultHandler): query["_id"] = ObjectId(result_id) self._get_one(query) - @swagger.operation(nickname="update") + @swagger.operation(nickname="Update a Test Result by result_id") def put(self, result_id): """ @description: update a single result by _id diff --git a/utils/test/testapi/opnfv_testapi/resources/result_models.py b/utils/test/testapi/opnfv_testapi/resources/result_models.py index f73f5c612..50445fc22 100644 --- a/utils/test/testapi/opnfv_testapi/resources/result_models.py +++ b/utils/test/testapi/opnfv_testapi/resources/result_models.py @@ -6,11 +6,12 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import models from opnfv_testapi.tornado_swagger import swagger @swagger.model() -class TIHistory(object): +class TIHistory(models.ModelBase): """ @ptype step: L{float} """ @@ -18,22 +19,9 @@ class TIHistory(object): self.date = date self.step = step - def format(self): - return { - "date": self.date, - "step": self.step - } - - @staticmethod - def from_dict(a_dict): - if a_dict is None: - return None - - return TIHistory(a_dict.get('date'), a_dict.get('step')) - @swagger.model() -class TI(object): +class TI(models.ModelBase): """ @property histories: trust_indicator update histories @ptype histories: C{list} of L{TIHistory} @@ -43,31 +31,13 @@ class TI(object): self.current = current self.histories = list() - def format(self): - hs = [] - for h in self.histories: - hs.append(h.format()) - - return { - "current": self.current, - "histories": hs - } - @staticmethod - def from_dict(a_dict): - t = TI() - if a_dict: - t.current = a_dict.get('current') - if 'histories' in a_dict.keys(): - for history in a_dict.get('histories', None): - t.histories.append(TIHistory.from_dict(history)) - else: - t.histories = [] - return t + def attr_parser(): + return {'histories': TIHistory} @swagger.model() -class ResultCreateRequest(object): +class ResultCreateRequest(models.ModelBase): """ @property trust_indicator: @ptype trust_indicator: L{TI} @@ -98,25 +68,9 @@ class ResultCreateRequest(object): self.criteria = criteria self.trust_indicator = trust_indicator if trust_indicator else TI(0) - def format(self): - return { - "pod_name": self.pod_name, - "project_name": self.project_name, - "case_name": self.case_name, - "installer": self.installer, - "version": self.version, - "start_date": self.start_date, - "stop_date": self.stop_date, - "details": self.details, - "build_tag": self.build_tag, - "scenario": self.scenario, - "criteria": self.criteria, - "trust_indicator": self.trust_indicator.format() - } - @swagger.model() -class ResultUpdateRequest(object): +class ResultUpdateRequest(models.ModelBase): """ @property trust_indicator: @ptype trust_indicator: L{TI} @@ -124,14 +78,9 @@ class ResultUpdateRequest(object): def __init__(self, trust_indicator=None): self.trust_indicator = trust_indicator - def format(self): - return { - "trust_indicator": self.trust_indicator.format(), - } - @swagger.model() -class TestResult(object): +class TestResult(models.ModelBase): """ @property trust_indicator: used for long duration test case @ptype trust_indicator: L{TI} @@ -156,63 +105,12 @@ class TestResult(object): self.trust_indicator = trust_indicator @staticmethod - def from_dict(a_dict): - - if a_dict is None: - return None - - t = TestResult() - t._id = a_dict.get('_id') - t.case_name = a_dict.get('case_name') - t.pod_name = a_dict.get('pod_name') - t.project_name = a_dict.get('project_name') - t.start_date = str(a_dict.get('start_date')) - t.stop_date = str(a_dict.get('stop_date')) - t.details = a_dict.get('details') - t.version = a_dict.get('version') - t.installer = a_dict.get('installer') - t.build_tag = a_dict.get('build_tag') - t.scenario = a_dict.get('scenario') - t.criteria = a_dict.get('criteria') - t.trust_indicator = TI.from_dict(a_dict.get('trust_indicator')) - return t - - def format(self): - return { - "case_name": self.case_name, - "project_name": self.project_name, - "pod_name": self.pod_name, - "start_date": str(self.start_date), - "stop_date": str(self.stop_date), - "version": self.version, - "installer": self.installer, - "details": self.details, - "build_tag": self.build_tag, - "scenario": self.scenario, - "criteria": self.criteria, - "trust_indicator": self.trust_indicator.format() - } - - def format_http(self): - return { - "_id": str(self._id), - "case_name": self.case_name, - "project_name": self.project_name, - "pod_name": self.pod_name, - "start_date": str(self.start_date), - "stop_date": str(self.stop_date), - "version": self.version, - "installer": self.installer, - "details": self.details, - "build_tag": self.build_tag, - "scenario": self.scenario, - "criteria": self.criteria, - "trust_indicator": self.trust_indicator.format() - } + def attr_parser(): + return {'trust_indicator': TI} @swagger.model() -class TestResults(object): +class TestResults(models.ModelBase): """ @property results: @ptype results: C{list} of L{TestResult} @@ -221,11 +119,5 @@ class TestResults(object): self.results = list() @staticmethod - def from_dict(a_dict): - if a_dict is None: - return None - - res = TestResults() - for result in a_dict.get('results'): - res.results.append(TestResult.from_dict(result)) - return res + def attr_parser(): + return {'results': TestResult} diff --git a/utils/test/testapi/opnfv_testapi/resources/testcase_handlers.py b/utils/test/testapi/opnfv_testapi/resources/testcase_handlers.py index 253aa6649..3692b164f 100644 --- a/utils/test/testapi/opnfv_testapi/resources/testcase_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/testcase_handlers.py @@ -22,7 +22,7 @@ class GenericTestcaseHandler(GenericApiHandler): class TestcaseCLHandler(GenericTestcaseHandler): - @swagger.operation(nickname="list-all") + @swagger.operation(nickname="List all TestCases by project_name") def get(self, project_name): """ @description: list all testcases of a project by project_name @@ -34,7 +34,7 @@ class TestcaseCLHandler(GenericTestcaseHandler): query['project_name'] = project_name self._list(query) - @swagger.operation(nickname="create") + @swagger.operation(nickname="Create a TestCase by project_name") def post(self, project_name): """ @description: create a testcase of a project by project_name @@ -72,7 +72,7 @@ class TestcaseCLHandler(GenericTestcaseHandler): class TestcaseGURHandler(GenericTestcaseHandler): - @swagger.operation(nickname='get-one') + @swagger.operation(nickname='Get a TestCase by project and case name') def get(self, project_name, case_name): """ @description: get a single testcase @@ -86,7 +86,7 @@ class TestcaseGURHandler(GenericTestcaseHandler): query["name"] = case_name self._get_one(query) - @swagger.operation(nickname="update") + @swagger.operation(nickname="Update a TestCase by project and case name") def put(self, project_name, case_name): """ @description: update a single testcase @@ -104,7 +104,7 @@ class TestcaseGURHandler(GenericTestcaseHandler): db_keys = ['name', 'project_name'] self._update(query, db_keys) - @swagger.operation(nickname='delete') + @swagger.operation(nickname='Delete a TestCase by project and case name') def delete(self, project_name, case_name): """ @description: delete a testcase by project_name and case_name diff --git a/utils/test/testapi/opnfv_testapi/resources/testcase_models.py b/utils/test/testapi/opnfv_testapi/resources/testcase_models.py index 0ed705f0f..8cc3c6c6a 100644 --- a/utils/test/testapi/opnfv_testapi/resources/testcase_models.py +++ b/utils/test/testapi/opnfv_testapi/resources/testcase_models.py @@ -6,11 +6,12 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import models from opnfv_testapi.tornado_swagger import swagger @swagger.model() -class TestcaseCreateRequest(object): +class TestcaseCreateRequest(models.ModelBase): def __init__(self, name, url=None, description=None, tier=None, ci_loop=None, criteria=None, blocking=None, dependencies=None, run=None, @@ -29,16 +30,9 @@ class TestcaseCreateRequest(object): self.version = version self.trust = "Silver" - def format(self): - return { - "name": self.name, - "description": self.description, - "url": self.url, - } - @swagger.model() -class TestcaseUpdateRequest(object): +class TestcaseUpdateRequest(models.ModelBase): def __init__(self, name=None, description=None, project_name=None, tier=None, ci_loop=None, criteria=None, blocking=None, dependencies=None, run=None, @@ -57,26 +51,9 @@ class TestcaseUpdateRequest(object): self.version = version self.trust = trust - def format(self): - return { - "name": self.name, - "description": self.description, - "project_name": self.project_name, - "tier": self.tier, - "ci_loop": self.ci_loop, - "criteria": self.criteria, - "blocking": self.blocking, - "dependencies": self.dependencies, - "run": self.run, - "domains": self.domains, - "tags": self.tags, - "version": self.version, - "trust": self.trust - } - @swagger.model() -class Testcase(object): +class Testcase(models.ModelBase): def __init__(self, _id=None, name=None, project_name=None, description=None, url=None, creation_date=None, tier=None, ci_loop=None, criteria=None, @@ -89,85 +66,20 @@ class Testcase(object): self.description = None self.url = None self.creation_date = None - self.tier=None - self.ci_loop=None - self.criteria=None - self.blocking=None - self.dependencies=None - self.run=None - self.domains=None - self.tags=None - self.version=None - self.trust=None - - @staticmethod - def from_dict(a_dict): - - if a_dict is None: - return None - - t = Testcase() - t._id = a_dict.get('_id') - t.project_name = a_dict.get('project_name') - t.creation_date = a_dict.get('creation_date') - t.name = a_dict.get('name') - t.description = a_dict.get('description') - t.url = a_dict.get('url') - t.tier = a_dict.get('tier') - t.ci_loop = a_dict.get('ci_loop') - t.criteria = a_dict.get('criteria') - t.blocking = a_dict.get('blocking') - t.dependencies = a_dict.get('dependencies') - t.run = a_dict.get('run') - t.domains = a_dict.get('domains') - t.tags = a_dict.get('tags') - t.version = a_dict.get('version') - t.trust = a_dict.get('trust') - - return t - - def format(self): - return { - "name": self.name, - "description": self.description, - "project_name": self.project_name, - "creation_date": str(self.creation_date), - "url": self.url, - "tier": self.tier, - "ci_loop": self.ci_loop, - "criteria": self.criteria, - "blocking": self.blocking, - "dependencies": self.dependencies, - "run": self.run, - "domains": self.domains, - "tags": self.tags, - "version": self.version, - "trust": self.trust - } - - def format_http(self): - return { - "_id": str(self._id), - "name": self.name, - "project_name": self.project_name, - "description": self.description, - "creation_date": str(self.creation_date), - "url": self.url, - "tier": self.tier, - "ci_loop": self.ci_loop, - "criteria": self.criteria, - "blocking": self.blocking, - "dependencies": self.dependencies, - "run": self.run, - "domains": self.domains, - "tags": self.tags, - "version": self.version, - "trust": self.trust - } + self.tier = None + self.ci_loop = None + self.criteria = None + self.blocking = None + self.dependencies = None + self.run = None + self.domains = None + self.tags = None + self.version = None + self.trust = None @swagger.model() -class Testcases(object): +class Testcases(models.ModelBase): """ @property testcases: @ptype testcases: C{list} of L{Testcase} @@ -176,11 +88,5 @@ class Testcases(object): self.testcases = list() @staticmethod - def from_dict(res_dict): - if res_dict is None: - return None - - res = Testcases() - for testcase in res_dict.get('testcases'): - res.testcases.append(Testcase.from_dict(testcase)) - return res + def attr_parser(): + return {'testcases': Testcase} diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_result.py b/utils/test/testapi/opnfv_testapi/tests/unit/test_result.py index 8479b35cd..10575a9f5 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/test_result.py +++ b/utils/test/testapi/opnfv_testapi/tests/unit/test_result.py @@ -25,12 +25,14 @@ class Details(object): self.timestart = timestart self.duration = duration self.status = status + self.items = [{'item1': 1}, {'item2': 2}] def format(self): return { "timestart": self.timestart, "duration": self.duration, - "status": self.status + "status": self.status, + 'items': [{'item1': 1}, {'item2': 2}] } @staticmethod @@ -43,6 +45,7 @@ class Details(object): t.timestart = a_dict.get('timestart') t.duration = a_dict.get('duration') t.status = a_dict.get('status') + t.items = a_dict.get('items') return t @@ -104,6 +107,7 @@ class TestResultBase(TestBase): self.assertEqual(details_res.duration, details_req.duration) self.assertEqual(details_res.timestart, details_req.timestart) self.assertEqual(details_res.status, details_req.status) + self.assertEqual(details_res.items, details_req.items) self.assertEqual(result.build_tag, req.build_tag) self.assertEqual(result.scenario, req.scenario) self.assertEqual(result.criteria, req.criteria) |