Fixes action result serialization
Attempt to serialize value that contained array of strings caused endless recursion. Change-Id: I5fe5b30b6d7ad6521a00ac3cbad21dccd812791d Closes-Bug: #1435437
This commit is contained in:
parent
bcb142cf7d
commit
4e54b4ef4c
@ -26,7 +26,8 @@ class ObjRef(object):
|
|||||||
|
|
||||||
|
|
||||||
def serialize_object(obj):
|
def serialize_object(obj):
|
||||||
if isinstance(obj, (collections.Sequence, collections.Set)):
|
if isinstance(obj, (collections.Sequence, collections.Set)) and not \
|
||||||
|
isinstance(obj, types.StringTypes):
|
||||||
return [serialize_object(t) for t in obj]
|
return [serialize_object(t) for t in obj]
|
||||||
elif isinstance(obj, collections.Mapping):
|
elif isinstance(obj, collections.Mapping):
|
||||||
result = {}
|
result = {}
|
||||||
|
@ -4,3 +4,15 @@ Properties:
|
|||||||
class2Property:
|
class2Property:
|
||||||
Contract: $.string().notNull()
|
Contract: $.string().notNull()
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
testMethod:
|
||||||
|
Body:
|
||||||
|
Return:
|
||||||
|
key1: abc
|
||||||
|
key2: [a, b, c]
|
||||||
|
key3: null
|
||||||
|
key4: false
|
||||||
|
key5:
|
||||||
|
x: y
|
||||||
|
key6:
|
||||||
|
- w: q
|
||||||
|
@ -17,6 +17,7 @@ import types
|
|||||||
|
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
|
from murano.dsl import serializer
|
||||||
from murano.tests.unit.dsl.foundation import object_model as om
|
from murano.tests.unit.dsl.foundation import object_model as om
|
||||||
from murano.tests.unit.dsl.foundation import test_case
|
from murano.tests.unit.dsl.foundation import test_case
|
||||||
|
|
||||||
@ -123,3 +124,21 @@ class TestResultsSerializer(test_case.DslTestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'John Snow',
|
'John Snow',
|
||||||
runner2.on(self._class1).testAttributes('John'))
|
runner2.on(self._class1).testAttributes('John'))
|
||||||
|
|
||||||
|
def test_value_deserialization(self):
|
||||||
|
"""Test serialization of arbitrary values that can be returned
|
||||||
|
from action methods
|
||||||
|
"""
|
||||||
|
|
||||||
|
runner = self.new_runner(self._class2)
|
||||||
|
result = runner.testMethod()
|
||||||
|
self.assertEqual(
|
||||||
|
{
|
||||||
|
'key1': 'abc',
|
||||||
|
'key2': ['a', 'b', 'c'],
|
||||||
|
'key3': None,
|
||||||
|
'key4': False,
|
||||||
|
'key5': {'x': 'y'},
|
||||||
|
'key6': [{'w': 'q'}]
|
||||||
|
},
|
||||||
|
serializer.serialize_object(result))
|
||||||
|
Loading…
Reference in New Issue
Block a user