Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pywps/inout/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ def from_json(cls, json_input):
elif json_input.get('href'):
instance.url = json_input['href']
elif json_input.get('data'):
instance.data = json_input['data']
data = json_input['data']
# remove cdata tag if it exists (issue #553)
if 'CDATA' in data:
data = data.replace("<![CDATA[", "").replace("]]>", "")
instance.data = data

return instance

Expand Down
19 changes: 10 additions & 9 deletions tests/test_inout.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,10 @@ def test_complex_input_file(self):
def test_complex_input_data(self):
complex = self.make_complex_input()
complex.data = "some data"
# the data is enclosed by a CDATA tag in json
assert complex.json['data'] == '<![CDATA[some data]]>'
# dump to json and load it again
complex2 = inout.inputs.ComplexInput.from_json(complex.json)
# the data is enclosed by a CDATA tag
complex._data = u'<![CDATA[{}]]>'.format(complex.data)
# it's expected that the file path changed
complex._file = complex2.file

Expand All @@ -300,13 +301,13 @@ def test_complex_input_data(self):
def test_complex_input_stream(self):
complex = self.make_complex_input()
complex.stream = StringIO("some data")
# the data is enclosed by a CDATA tag in json
assert complex.json['data'] == '<![CDATA[some data]]>'
# dump to json and load it again
complex2 = inout.inputs.ComplexInput.from_json(complex.json)

# the serialized stream becomes a data type
# we hard-code it for the testing comparison
complex.prop = 'data'
# the data is enclosed by a CDATA tag
complex._data = u'<![CDATA[{}]]>'.format(complex.data)
# it's expected that the file path changed
complex._file = complex2.file

Expand Down Expand Up @@ -682,8 +683,8 @@ class LiteralOutputTest(unittest.TestCase):
def setUp(self):

self.literal_output = inout.outputs.LiteralOutput(
"literaloutput",
data_type="integer",
"literaloutput",
data_type="integer",
title="Literal Output",
translations={"fr-CA": {"title": "Mon output", "abstract": "Une description"}},
)
Expand Down Expand Up @@ -714,8 +715,8 @@ class BBoxInputTest(unittest.TestCase):
def setUp(self):

self.bbox_input = inout.inputs.BoundingBoxInput(
"bboxinput",
title="BBox input",
"bboxinput",
title="BBox input",
dimensions=2,
translations={"fr-CA": {"title": "Mon input", "abstract": "Une description"}},
)
Expand Down