Skip to content
Snippets Groups Projects
Verified Commit 904a4826 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Ensure we render tag text properly in Subsonic XML

parent 9376f808
No related branches found
No related tags found
No related merge requests found
......@@ -53,5 +53,8 @@ def dict_to_xml_tree(root_tag, d, parent=None):
for obj in value:
root.append(dict_to_xml_tree(key, obj, parent=root))
else:
root.set(key, str(value))
if key == "value":
root.text = str(value)
else:
root.set(key, str(value))
return root
......@@ -67,9 +67,12 @@ def test_json_renderer():
def test_xml_renderer_dict_to_xml():
payload = {"hello": "world", "item": [{"this": 1}, {"some": "node"}]}
payload = {
"hello": "world",
"item": [{"this": 1, "value": "text"}, {"some": "node"}],
}
expected = """<?xml version="1.0" encoding="UTF-8"?>
<key hello="world"><item this="1" /><item some="node" /></key>"""
<key hello="world"><item this="1">text</item><item some="node" /></key>"""
result = renderers.dict_to_xml_tree("key", payload)
exp = ET.fromstring(expected)
assert ET.tostring(result) == ET.tostring(exp)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment