fix(subsonic): AttributeError when getting user profile

This commit is contained in:
Alexandra Parker 2021-09-05 13:56:34 +00:00 committed by Georg Krause
parent 971529efee
commit 79587b801e
3 changed files with 9 additions and 2 deletions

View File

@ -75,7 +75,12 @@ def dict_to_xml_tree(root_tag, d, parent=None):
root.append(dict_to_xml_tree(key, value, parent=root))
elif isinstance(value, list):
for obj in value:
root.append(dict_to_xml_tree(key, obj, parent=root))
if isinstance(obj, dict):
el = dict_to_xml_tree(key, obj, parent=root)
else:
el = ET.Element(key)
el.text = str(obj)
root.append(el)
else:
if key == "value":
root.text = str(value)

View File

@ -70,9 +70,10 @@ def test_xml_renderer_dict_to_xml():
payload = {
"hello": "world",
"item": [{"this": 1, "value": "text"}, {"some": "node"}],
"list": [1, 2],
}
expected = """<?xml version="1.0" encoding="UTF-8"?>
<key hello="world"><item this="1">text</item><item some="node" /></key>"""
<key hello="world"><item this="1">text</item><item some="node" /><list>1</list><list>2</list></key>"""
result = renderers.dict_to_xml_tree("key", payload)
exp = ET.fromstring(expected)
assert ET.tostring(result) == ET.tostring(exp)

View File

@ -0,0 +1 @@
Fix an error in a Subsonic methods that return lists of numbers/strings like getUser