def test_serialize_xml(): data = { 'status': 'ok', 'artists': [{ 'name': 'Jean Michel Jarre', 'year': 1948, 'cities': ['Paris', 'Lyon'] }] } resp = serialize_xml(data) assert_equals('text/xml; charset=UTF-8', resp.content_type) expected = '''<?xml version='1.0' encoding='UTF-8'?>\n<response><status>ok</status><artists><artist><cities><city>Paris</city><city>Lyon</city></cities><name>Jean Michel Jarre</name><year>1948</year></artist></artists></response>''' assert_equals(expected, resp.data)
def test_serialize_xml_attribute(): data = {'@status': 'ok'} resp = serialize_xml(data) assert_equals('text/xml; charset=UTF-8', resp.content_type) expected = '''<?xml version='1.0' encoding='UTF-8'?>\n<response status="ok" />''' assert_equals(expected, resp.data)
def test_serialize_xml(): data = {'status': 'ok', 'artists': [{'name': 'Jean Michel Jarre', 'year': 1948, 'cities': ['Paris', 'Lyon']}]} resp = serialize_xml(data) assert_equals('text/xml; charset=UTF-8', resp.content_type) expected = '''<?xml version='1.0' encoding='UTF-8'?>\n<response><status>ok</status><artists><artist><cities><city>Paris</city><city>Lyon</city></cities><name>Jean Michel Jarre</name><year>1948</year></artist></artists></response>''' assert_equals(expected, resp.data)