Beispiel #1
0
    def start(self):
        """
        Start the bot

        Calling this method when the bot has already started will result
        in an Exception being raised.
        """
        if self.bot_thread is not None:
            raise Exception("Bot has already been started")
        self._bot = setup_bot('Test', self.logger, self.bot_config)
        self.bot_thread = Thread(target=self.bot.serve_forever,
                                 name='TestBot main thread')
        self.bot_thread.setDaemon(True)
        self.bot_thread.start()

        self.bot.push_message("!echo ready")

        # Ensure bot is fully started and plugins are loaded before returning
        for i in range(60):
            #  Gobble initial error messages...
            if self.bot.pop_message(timeout=1) == "ready":
                break
        else:
            raise AssertionError(
                'The "ready" message has not been received (timeout).')
Beispiel #2
0
    def start(self, timeout=2):
        """
        Start the bot

        Calling this method when the bot has already started will result
        in an Exception being raised.
        :param timeout: Timeout for the ready message pop. pop will be done 60 times so the total timeout is 60*timeout
        """
        if self.bot_thread is not None:
            raise Exception("Bot has already been started")
        self._bot = setup_bot('Test', self.logger, self.bot_config)
        self.bot_thread = Thread(target=self.bot.serve_forever,
                                 name='TestBot main thread')
        self.bot_thread.setDaemon(True)
        self.bot_thread.start()

        self.bot.push_message("!echo ready")

        # Ensure bot is fully started and plugins are loaded before returning
        try:
            for i in range(60):
                #  Gobble initial error messages...
                msg = self.bot.pop_message(timeout=timeout)
                if msg == "ready":
                    break
                log.warning(
                    "Queue was not empty, the non-consumed message is:")
                log.warning(msg)
                log.warning(
                    "Check the previous test and remove spurrious messages.")
        except Empty:
            raise AssertionError(
                'The "ready" message has not been received (timeout).')
Beispiel #3
0
    def start(self):
        """
        Start the bot

        Calling this method when the bot has already started will result
        in an Exception being raised.
        """
        if self.bot_thread is not None:
            raise Exception("Bot has already been started")
        self._bot = setup_bot('Test', self.logger, self.bot_config)

        def runbot():
            self._bot.serve_forever()
            self._bot.shutdown()

        self.bot_thread = Thread(target=runbot, name='TestBot main thread')
        self.bot_thread.setDaemon(True)
        self.bot_thread.start()

        self.bot.push_message("!echo ready")

        # Ensure bot is fully started and plugins are loaded before returning
        for i in range(60):
            #  Gobble initial error messages...
            if self.bot.pop_message(timeout=1) == "ready":
                break
        else:
            raise AssertionError('The "ready" message has not been received (timeout).')
Beispiel #4
0
    def start(self, timeout=2):
        """
        Start the bot

        Calling this method when the bot has already started will result
        in an Exception being raised.
        :param timeout: Timeout for the ready message pop. pop will be done 60 times so the total timeout is 60*timeout
        """
        if self.bot_thread is not None:
            raise Exception("Bot has already been started")
        self._bot = setup_bot('Test', self.logger, self.bot_config)
        self.bot_thread = Thread(target=self.bot.serve_forever, name='TestBot main thread')
        self.bot_thread.setDaemon(True)
        self.bot_thread.start()

        self.bot.push_message("!echo ready")
Beispiel #5
0
    def start(self):
        """
        Start the bot

        Calling this method when the bot has already started will result
        in an Exception being raised.
        """
        if self.bot_thread is not None:
            raise Exception("Bot has already been started")
        self.bot = setup_bot('Test', self.logger, self.bot_config)
        self.bot_thread = Thread(target=self.bot.serve_forever, name='TestBot main thread')
        self.bot_thread.setDaemon(True)
        self.bot_thread.start()

        self.bot.push_message("!echo ready")

        # Ensure bot is fully started and plugins are loaded before returning
        assert self.bot.pop_message(timeout=60) == "ready"