summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)