Ejemplo n.º 1
0
    def __init__(self, name, login, chatname, modules, session):
        TestBot.__init__(self, name, login, chatname, modules, session)
        self.client_facto = MultiClientEchoFactory(self)
        self.color = random.choice(nickname_colors)

        # Have to disable this error in pylint, why ?
        # pylint: disable=E1101
        reactor.listenTCP(8123, self.client_facto)
        reactor.run()
Ejemplo n.º 2
0
    def __init__(self, name, login, chatname, modules, session):
        TestBot.__init__(self, name, login, chatname, modules, session)
        self.client_facto = MultiClientEchoFactory(self)
        self.color = random.choice(nickname_colors)

        # Have to disable this error in pylint, why ?
        # pylint: disable=E1101
        reactor.listenTCP(8123, self.client_facto)
        reactor.run()
Ejemplo n.º 3
0
    def run(self):
        
        #
        # The different types of execution
        #

        # Only check modules: exit right after loading
        if self._config.only_check:
            self._load_modules(self._config.rooms)
            LOGGER.info("All modules checked, exiting…")

        # Test mode : load test room
        elif self._config.unit_test or self._config.script or \
             self._config.interract :

            test_room = self._config.test_room
            if test_room is None :
                _abort("Please define a test section in the configuration")
            e, m = self._load_modules([test_room])
            if e :
                _abort("Unable to load all test modules")

            # Unit test mode : run unittest
            if self._config.unit_test:
                bot = TestBot(test_room.nick, test_room.login,
                              test_room.chan, m[test_room].modules, self._db_session)
                suite = unittest.TestSuite()
                for test in m[test_room].test_mods:
                    suite.addTests(ModuleTest.parametrize(test, bot=bot))
                unittest.TextTestRunner(verbosity=2).run(suite)
            # Script mode
            elif self._config.script:
                bot = TestBot(test_room.nick, test_room.login,
                              test_room.chan, m[test_room].modules, self._db_session)
                for msg in self._config.script.split(";"):
                    print "--> %s" % msg
                    print "<== %s" % bot.create_msg("bob", msg)
            # Interract/twisted mode
            elif self._config.interract:
                # We import it here so the bot does not 'depend' on twisted
                # unless you *really* want to use the --interract mode
                from pipobot.bot_twisted import TwistedBot
                bot = TwistedBot(test_room.nick, test_room.login,
                                 test_room.chan, m[test_room].modules, self._db_session)
        # Standard mode
        else:
            rooms = self._config.rooms
            e, m = self._load_modules(rooms)
            if e :
                _abort("Unable to load all modules")

            self._jabber_bot(rooms, m)

        LOGGER.debug("Exiting…")
        logging.shutdown()
        del self._config
Ejemplo n.º 4
0
    def run(self):

        #
        # The different types of execution
        #

        # Only check modules: exit right after loading
        if self._config.only_check:
            self._load_modules(self._config.rooms)
            LOGGER.info("All modules checked, exiting…")

        # Test mode : load test room
        elif self._config.unit_test or self._config.script or \
             self._config.interract :

            test_room = self._config.test_room
            if test_room is None:
                _abort("Please define a test section in the configuration")
            e, m = self._load_modules([test_room])
            if e:
                _abort("Unable to load all test modules")

            # Unit test mode : run unittest
            if self._config.unit_test:
                bot = TestBot(test_room.nick, test_room.login, test_room.chan,
                              m[test_room].modules, self._db_session)
                suite = unittest.TestSuite()
                for test in m[test_room].test_mods:
                    suite.addTests(ModuleTest.parametrize(test, bot=bot))
                unittest.TextTestRunner(verbosity=2).run(suite)
            # Script mode
            elif self._config.script:
                bot = TestBot(test_room.nick, test_room.login, test_room.chan,
                              m[test_room].modules, self._db_session)
                for msg in self._config.script.split(";"):
                    print "--> %s" % msg
                    print "<== %s" % bot.create_msg("bob", msg)
            # Interract/twisted mode
            elif self._config.interract:
                # We import it here so the bot does not 'depend' on twisted
                # unless you *really* want to use the --interract mode
                from pipobot.bot_twisted import TwistedBot
                bot = TwistedBot(test_room.nick, test_room.login,
                                 test_room.chan, m[test_room].modules,
                                 self._db_session)
        # Standard mode
        else:
            rooms = self._config.rooms
            e, m = self._load_modules(rooms)
            if e:
                _abort("Unable to load all modules")

            self._jabber_bot(rooms, m)

        LOGGER.debug("Exiting…")
        logging.shutdown()
        del self._config
Ejemplo n.º 5
0
def create_test_bot(mods):
    engine = create_engine('sqlite:///:memory:')
    Session = sessionmaker(bind=engine)
    session = Session()
    Base.metadata.create_all(engine)
    return TestBot("pipotest", "login", CHAN, mods, session)