@@ -291,6 +291,34 @@ def test_complex_input_binary_data(self):
291291 assert complex .json ['data' ] == '<![CDATA[some data]]>'
292292 self .assertEqual (complex .prop , 'data' )
293293
294+ def test_complex_input_data_with_binary_data_format (self ):
295+ complex = inout .inputs .ComplexInput (
296+ identifier = "complexinput" ,
297+ title = 'MyComplex' ,
298+ abstract = 'My complex input' ,
299+ keywords = ['kw1' , 'kw2' ],
300+ workdir = self .tmp_dir ,
301+ supported_formats = [FORMATS .ZIP ],
302+ metadata = [Metadata ("special data" )],
303+ default = "/some/file/path" ,
304+ default_type = SOURCE_TYPE .FILE ,
305+ translations = {"fr-CA" : {"title" : "Mon input" , "abstract" : "Une description" }},
306+ data_format = FORMATS .ZIP
307+ )
308+ complex .as_reference = False
309+ complex .method = "GET"
310+ complex .max_size = 1000
311+ complex .data = b"some data"
312+ # the data is enclosed by a CDATA tag in json
313+ assert complex .json ['data' ] == 'c29tZSBkYXRh'
314+ # dump to json and load it again
315+ complex2 = inout .inputs .ComplexInput .from_json (complex .json )
316+
317+ self .assert_complex_equals (complex , complex2 )
318+ self .assertEqual (complex .prop , 'data' )
319+ self .assertEqual (complex2 .prop , 'data' )
320+ self .assertEqual (complex .data , complex2 .data )
321+
294322 def test_complex_input_stream (self ):
295323 complex = self .make_complex_input ()
296324 complex .stream = StringIO ("{'name': 'test', 'input1': ']]'}" )
0 commit comments