def setUp(self): JCLTestCase.setUp(self, tables=[User, Account, ExampleAccount]) self.comp = JCLComponent("jcl.test.com", "password", "localhost", "5347", self.db_url) self.handler = DefaultVCardHandler(self.comp) self.comp.config = ConfigParser() self.comp.config.read("src/jcl/tests/jcl.conf")
class DefaultVCardHandler_TestCase(JCLTestCase): def setUp(self): JCLTestCase.setUp(self, tables=[User, Account, ExampleAccount]) self.comp = JCLComponent("jcl.test.com", "password", "localhost", "5347", self.db_url) self.handler = DefaultVCardHandler(self.comp) self.comp.config = ConfigParser() self.comp.config.read("src/jcl/tests/jcl.conf") def test_filter(self): """Test DefaultVCardHandler filter. Accept any stanza""" self.assertEquals(self.handler.filter(None, None), True) def test_handle(self): """Test default VCard returned""" result = self.handler.handle(Iq(from_jid="jcl.test.com", to_jid="*****@*****.**", stanza_type="get"), Lang.en, True) self.assertEquals(len(result), 1) result[0].xmlnode.setNs(None) self.assertTrue(jcl.tests.is_xml_equal(\ u"<iq from='*****@*****.**' to='jcl.test.com' type='result'>" + "<vCard xmlns='vcard-temp'>" + "<URL>" + self.comp.config.get("vcard", "url") + "</URL>" + "<N><FAMILY>" + self.comp.name + "</FAMILY>" + "<GIVEN></GIVEN>" + "<MIDDLE></MIDDLE>" + "<PREFIX></PREFIX>" + "<SUFFIX></SUFFIX></N>" + "<FN>" + self.comp.name + "</FN>" + "</vCard></iq>", result[0].xmlnode, True))