Example #1
0
    def test_getting_existing_commandhandlers(self):
        """ If any of the two known command handlers are configured, an instance
        of the named command handler should be returned by get_command_handler
        """

        mock_file = self.mox.CreateMockAnything()
        mock_file.closed = False
        mock_file.name = "foobar"

        self.mox.StubOutWithMock(SafeConfigParser, "get")

        config = ConfigurationParser()
        config.parse(mock_file)

        # case this one wierdly just to make sure that character casing is taken
        # into consideration when parsing the string..
        config.get("general", "handler").AndReturn("rEstrIctEd")

        config.get("general", "handler").AndReturn("pAssthrU")

        self.mox.ReplayAll()

        expected_type = commandhandlers.RestrictedCommandHandler()
        self.assertEquals(type(get_command_handler()),
                          type(expected_type))

        expected_type = commandhandlers.UnsafeCommandHandler()
        self.assertEquals(type(get_command_handler()),
                          type(expected_type))
Example #2
0
    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])