diff --git a/murano/dsl/serializer.py b/murano/dsl/serializer.py index 3a367b63..2b9cfd0c 100644 --- a/murano/dsl/serializer.py +++ b/murano/dsl/serializer.py @@ -26,7 +26,8 @@ class ObjRef(object): 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] elif isinstance(obj, collections.Mapping): result = {} diff --git a/murano/tests/unit/dsl/meta/SampleClass2.yaml b/murano/tests/unit/dsl/meta/SampleClass2.yaml index 884f4fcc..cee148cd 100644 --- a/murano/tests/unit/dsl/meta/SampleClass2.yaml +++ b/murano/tests/unit/dsl/meta/SampleClass2.yaml @@ -4,3 +4,15 @@ Properties: class2Property: Contract: $.string().notNull() +Methods: + testMethod: + Body: + Return: + key1: abc + key2: [a, b, c] + key3: null + key4: false + key5: + x: y + key6: + - w: q diff --git a/murano/tests/unit/dsl/test_results_serializer.py b/murano/tests/unit/dsl/test_results_serializer.py index af2b08d1..83d7fc2f 100644 --- a/murano/tests/unit/dsl/test_results_serializer.py +++ b/murano/tests/unit/dsl/test_results_serializer.py @@ -17,6 +17,7 @@ import types 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 test_case @@ -123,3 +124,21 @@ class TestResultsSerializer(test_case.DslTestCase): self.assertEqual( 'John Snow', 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))