@@ -25,18 +25,17 @@ def test_register_message_schema(message_class, expected_name):
2525 assert iop_schema .Category == expected_name
2626 assert iop_schema .Name == expected_name
2727
28- @pytest .mark .parametrize ("json_data,classname, path,expected" , [
29- ('{"string":"Foo", "integer":42}' , 'registerFilesIop.message.SimpleMessage' , ' string' , 'Foo' ),
30- ('{"post":{"Title":"Foo"}, "string":"bar", "list_str":["Foo","Bar"]}' , 'registerFilesIop.message.ComplexMessage' , ' post.Title' , 'Foo' ),
31- ('{"post":{"Title":"Foo"}, "list_post":[{"Title":"Bar"},{"Title":"Foo"}]}' , 'registerFilesIop.message.ComplexMessage' , ' list_post(2).Title' , 'Foo' ),
32- ('{"list_str":["Foo","Bar"]}' , 'registerFilesIop.message.ComplexMessage' , ' list_str(2)' , 'Bar' ),
33- ('{"list_str":["Foo","Bar"]}' , 'registerFilesIop.message.ComplexMessage' , ' list_str()' , ['Foo' ,'Bar' ]),
34- ('{"list_str":["Foo","Bar"]}' , 'registerFilesIop.message.ComplexMessage' , ' list_str' , ['Foo' ,'Bar' ]),
35- ('{"list":["Foo","sub_list": ["Bar","Baz"]]}' , 'registerFilesIop.message.ComplexMessage' , ' list().sub_list (2)' , 'Baz' ),
28+ @pytest .mark .parametrize ("json_data,path,expected" , [
29+ ('{"string":"Foo", "integer":42}' , 'string' , 'Foo' ),
30+ ('{"post":{"Title":"Foo"}, "string":"bar", "list_str":["Foo","Bar"]}' , 'post.Title' , 'Foo' ),
31+ ('{"post":{"Title":"Foo"}, "list_post":[{"Title":"Bar"},{"Title":"Foo"}]}' , 'list_post(2).Title' , 'Foo' ),
32+ ('{"list_str":["Foo","Bar"]}' , 'list_str(2)' , 'Bar' ),
33+ ('{"list_str":["Foo","Bar"]}' , 'list_str()' , ['Foo' ,'Bar' ]),
34+ ('{"list_str":["Foo","Bar"]}' , 'list_str' , ['Foo' ,'Bar' ]),
35+ ('{"list":["Foo",["Bar","Baz"]]}' , 'list(2) (2)' , 'Baz' ),
3636])
37- def test_get_value_at (iop_message , json_data , classname , path , expected ):
37+ def test_get_value_at (iop_message , json_data , path , expected ):
3838 iop_message .json = json_data
39- iop_message .classname = classname
4039 result = iop_message .GetValueAt (path )
4140 assert result == expected
4241
@@ -70,7 +69,7 @@ def test_set_value_at(iop_message, json_data, path, value, action, key, expected
7069 'Foo'
7170 )
7271])
73- def test_transform (load_cls_files , iop_message , json_data , classname , transform_class , expected_value ):
72+ def test_get_transform (load_cls_files , iop_message , json_data , classname , transform_class , expected_value ):
7473 ref = iris .ref (None )
7574 iop_message .json = json_data
7675 iop_message .classname = classname
@@ -79,3 +78,24 @@ def test_transform(load_cls_files, iop_message, json_data, classname, transform_
7978 result = ref .value
8079
8180 assert result .StringValue == expected_value
81+
82+ def test_set_transform (load_cls_files ):
83+ ref = iris .ref (None )
84+ message = iris .cls ('Ens.StringRequest' )._New ()
85+ message .StringValue = 'Foo'
86+
87+ _Utils .raise_on_error (iris .cls ('UnitTest.SimpleMessageSet' ).Transform (message , ref ))
88+ result = ref .value
89+
90+ assert json .loads (result .json ) == json .loads ('{"string":"Foo"}' )
91+
92+ def test_set_transform_vdoc (load_cls_files , iop_message ):
93+ ref = iris .ref (None )
94+ iop_message .json = '{"string":"Foo", "integer":42}'
95+ iop_message .classname = 'registerFilesIop.message.SimpleMessage'
96+
97+ _Utils .raise_on_error (iris .cls ('UnitTest.SimpleMessageSetVDoc' ).Transform (iop_message , ref ))
98+ result = ref .value
99+
100+ assert json .loads (result .json ) == json .loads ('{"string":"Foo"}' )
101+ assert result .classname == 'registerFilesIop.message.SimpleMessage'
0 commit comments