def test_cell_deserializer(self): caps_dict = {'cap1': 'a;b', 'cap2': 'c;d'} caps_xml = ("<capabilities><cap1>a;b</cap1>" "<cap2>c;d</cap2></capabilities>") expected = {'cell': {'name': 'testcell1', 'type': 'child', 'rpc_host': 'localhost', 'capabilities': caps_dict}} intext = ("<?xml version='1.0' encoding='UTF-8'?>\n" "<cell><name>testcell1</name><type>child</type>" "<rpc_host>localhost</rpc_host>" "%s</cell>") % caps_xml deserializer = cells_ext.CellDeserializer() result = deserializer.deserialize(intext) self.assertEqual(dict(body=expected), result)
def test_with_corrupt_xml(self): deserializer = cells_ext.CellDeserializer() self.assertRaises(exception.MalformedRequestBody, deserializer.deserialize, utils.killer_xml_body())