def test_ask(self): logging.info("******** ask") class MyBot(FakeBot): def say(self, message, **kwargs): self.engine.set('said', message) self.bot = MyBot(engine=self.engine) self.bot.subscriber = self.engine.bus.subscribe('*id') self.bot.publisher = self.engine.publisher machine = Input(bot=self.bot, question="What's up, Doc?") machine.listen = mock.Mock() machine.ask() self.assertEqual(self.engine.get('said'), machine.question) machine.listen.assert_called_with() machine = Input(bot=self.bot, question_content="What's *up*, Doc?") machine.listen = mock.Mock() machine.ask() self.assertEqual(self.engine.get('said'), ' ') machine.listen.assert_called_with()
def test_listen(self): logging.info("******** listen") machine = Input(bot=self.bot, question="What's up, Doc?") self.engine.set('general.switch', 'off') p = machine.listen() p.join()