def test_xml(self): xml = """ <a a1="1" a2="2"> <bs><b>1</b><b>2</b><b>3</b><b><c c1="1"/></b></bs> <d><e>1</e></d> <f>1</f> </a> """.strip() as_dict = { 'body': { 'a': { 'a1': '1', 'a2': '2', 'bs': ['1', '2', '3', { 'c': { 'c1': '1' } }], 'd': { 'e': '1' }, 'f': '1', }, }, } metadata = {'plurals': {'bs': 'b', 'ts': 't'}} deserializer = wsgi.XMLDeserializer(metadata=metadata) self.assertEqual(deserializer.deserialize(xml), as_dict)
def test_deserializer(self): deserializer = wsgi.XMLDeserializer() expected = dict(extra_specs={"key1": "value1"}) intext = ("<?xml version='1.0' encoding='UTF-8'?>\n" '<extra_specs><key1>value1</key1></extra_specs>') result = deserializer.deserialize(intext)['body'] self.assertEqual(result, expected)
def test_xml_empty(self): xml = """<a></a>""" as_dict = {"body": {"a": {}}} deserializer = wsgi.XMLDeserializer() self.assertEqual(deserializer.deserialize(xml), as_dict)
def setUp(self): super(KeypairsXMLSerializerTest, self).setUp() self.deserializer = wsgi.XMLDeserializer()
def setUp(self): super(QuotaXMLSerializerTest, self).setUp() self.serializer = quotas.QuotaTemplate() self.deserializer = wsgi.XMLDeserializer()