def test_it_registers_a_command(self): def a_command(request: CommandRequest): pass bot = TelegramBot(token='123') bot.register_command('cmd', a_command) self.expect_command_handler_is_registered('cmd')
def test_command_request_message(self): update = Update(update_id=0, message=self.message) context = CallbackContext(self.dispatcher) bot = TelegramBot(token='123') def a_command(request: CommandRequest): assert request.message is update.message bot.register_command('command', a_command) self.inject_command('command', update, context)
def test_it_runs_command(self): command_callback = MagicMock() def a_command(request: CommandRequest): command_callback() bot = TelegramBot(token='123') bot.register_command('command', a_command) self.inject_dummy_command('command') command_callback.assert_called_once()