def test_data_parse_vanilla_xml(self): """Tests parsing valid XML data.""" lines = [ '<?xml version="1.0" encoding="UTF-8"?>', '<note type="hi"><to>Tove</to><from>Jani</from></note>' ] dat = parser._parse_data(lines) self.assertEqual("note", dat.tag) self.assertEqual({"type": "hi"}, dat.attrib) self.assertEqual("to", dat[0].tag) self.assertEqual("Tove", dat[0].text) self.assertEqual({}, dat[0].attrib) self.assertEqual("from", dat[1].tag) self.assertEqual("Jani", dat[1].text) self.assertEqual({}, dat[1].attrib)
def test_data_parse_vanilla_postdat(self): """Tests parsing valid POST (form) data.""" lines = ["var=val&var2=val2"] dat = parser._parse_data(lines) self.assertEqual("var=val&var2=val2", dat)
def test_data_parse_vanilla_json(self): """Tests parsing valid JSON data.""" lines = ['{"a": "val", "b": "val2"}'] dat = parser._parse_data(lines) self.assertEqual({"a": "val", "b": "val2"}, dat)