def test_say_cancel(self): logging.info("******** say_cancel") class MyBot(FakeBot): def on_init(self): self.said = [] def say(self, message, content=None, file=None): if message: self.said.append(message) if content: self.said.append(content) if file: self.said.append(file) self.bot = MyBot(engine=self.engine) self.bot.subscriber = self.engine.bus.subscribe('*id') self.bot.publisher = self.engine.publisher machine = Menu(bot=self.bot, question="What's up, Doc?", options=["option 1", "option 2"]) self.bot.said = [] machine.say_cancel() self.assertEqual(self.bot.said, [machine.CANCEL_MESSAGE]) machine = Menu( bot=self.bot, question="What's up, Doc?", options=["option 1", "option 2"], on_cancel="Ok, forget about it", on_cancel_content="*cancelled*", on_cancel_file="/file/to/upload.pdf", ) self.bot.said = [] machine.say_cancel() self.assertEqual( self.bot.said, ['Ok, forget about it', ' ', '*cancelled*', '/file/to/upload.pdf'])
def test_cancel(self): logging.info("******** cancel") machine = Menu(bot=self.bot, question="What's up, Doc?", options=["option 1", "option 2"]) machine.say_cancel = mock.Mock() machine.stop = mock.Mock() machine.cancel() self.assertTrue(machine.say_cancel.called) self.assertTrue(machine.stop.called)