def test_get_features(self): """ Make sure that we have a handler for each feature. """ mock_iq = self.mox.CreateMockAnything() new_mock_iq = self.mox.CreateMockAnything() mock_query = self.mox.CreateMockAnything() mock_iq.make_result_response().AndReturn(new_mock_iq) new_mock_iq.new_query(mox.IgnoreArg()).AndReturn(mock_query) mock_query.ns() mock_query.newTextChild( mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()) mock_query.ns() mock_query.newTextChild( mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()) self.mox.ReplayAll() version_handler = VersionHandler() features = version_handler.get_features() for feat in features: got_handler = False for (element, namespace, handler) in \ version_handler.get_iq_get_handlers(): if namespace == feat: got_handler = True self.assertNotEqual(None, handler(mock_iq)) break self.assertTrue(got_handler)
def test__init__(self): """ Ensure that the proper superclass methods are called and that the interface providers are set. """ jid = JID(self.__usr) jid = JID(jid.node, jid.domain, "XMPPMote") self.mox.StubOutWithMock(JabberClient, "__init__") self.mox.StubOutWithMock(commands, "get_command_handler") self.mox.StubOutWithMock(VersionHandler, "__init__") JabberClient.__init__(mox.IgnoreArg(), jid, self.__pwd, disco_name = "XMPPMote", disco_type = "bot", tls_settings = None) VersionHandler.__init__() commands.get_command_handler().AndReturn("foobar") self.mox.ReplayAll() cli = Client(JID(self.__usr), self.__pwd) self.assertTrue(isinstance(cli.interface_providers[0], VersionHandler)) self.assertEquals("foobar", cli.interface_providers[1])
def test_set_features(self): """ Testing the set handlers of the Client. """ self.mox.ReplayAll() version_handler = VersionHandler() self.assertEquals([], version_handler.get_iq_set_handlers())