summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-12-23 15:31:14 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-12-23 15:36:43 +0800
commit53ed9e36a13d03455fc04b3f54ed290037359f6b (patch)
treea962991cf77c17566c4a808e503835c47fcc2ee5 /utils/test/testapi/opnfv_testapi
parent59f96c0b4fb704339bf45c8af943070f6adcf7b9 (diff)
bugfix: access results failed of Test API
File "/Users/fengxiaowei/opnfv/releng/utils/test/testapi/venv/lib/python2.7/site-packages/opnfv_testapi/resources/models.py", line 47, in format_http return self._format([]) File "/Users/fengxiaowei/opnfv/releng/utils/test/testapi/venv/lib/python2.7/site-packages/opnfv_testapi/resources/models.py", line 37, in _format hs.append(h.format()) AttributeError: 'dict' object has no attribute 'format' JIRA: FUNCTEST-676 Change-Id: I9d8d8a31e5580be51fb690628a03d452742f12d4 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils/test/testapi/opnfv_testapi')
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/models.py7
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/test_result.py6
2 files changed, 8 insertions, 5 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/models.py b/utils/test/testapi/opnfv_testapi/resources/models.py
index c85c1d5b1..a281c66d8 100644
--- a/utils/test/testapi/opnfv_testapi/resources/models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/models.py
@@ -24,7 +24,6 @@ class ModelBase(object):
def _format(self, excludes):
new_obj = copy.deepcopy(self)
dicts = new_obj.__dict__
- print self, self.__class__
for k in dicts.keys():
if k in excludes:
del dicts[k]
@@ -32,9 +31,9 @@ class ModelBase(object):
if hasattr(dicts[k], 'format'):
dicts[k] = dicts[k].format()
elif isinstance(dicts[k], list):
- hs = []
- for h in dicts[k]:
- hs.append(h.format())
+ 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])
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)