async def test_handle_delegated_handler( self, command_processor: CommandProcessor, boolean2: Tuple[bool, bool], mocker: MockFixture) -> None: mocker.patch('mautrix_telegram.user.config', self.config) mocker.patch('mautrix.bridge.commands.handler.command_handlers', { "help": AsyncMock(), "unknown-command": AsyncMock() }) sender = u.User(UserID("@sender:example.org")) sender.command_status = {"foo": AsyncMock(), "next": AsyncMock()} result = await command_processor.handle( room_id=RoomID("#mock_room:example.org"), event_id=EventID("$H45H:example.org"), sender=sender, # u.User command="foo", args=[], is_management=boolean2[0], is_portal=boolean2[1]) assert result is None command_handlers = mautrix.bridge.commands.handler.command_handlers command_handlers["help"].mock.assert_not_called() # type: ignore command_handlers["unknown-command"].mock.assert_not_called( ) # type: ignore sender.command_status["foo"].mock.assert_not_called() # type: ignore sender.command_status["next"].mock.assert_called_once() # type: ignore
async def test_handle(self, command_processor: CommandProcessor, boolean2: Tuple[bool, bool], mocker: MockFixture) -> None: mocker.patch('mautrix_telegram.user.config', self.config) mocker.patch('mautrix_telegram.commands.handler.command_handlers', { "help": AsyncMock(), "unknown-command": AsyncMock() }) sender = u.User(MatrixUserID("@sender:example.org")) result = await command_processor.handle( room=MatrixRoomID("#mock_room:example.org"), event_id=MatrixEventID("$H45H:example.org"), sender=sender, command="hElp", args=[], is_management=boolean2[0], is_portal=boolean2[1], ) assert result is None command_handlers = mautrix_telegram.commands.handler.command_handlers command_handlers["help"].mock.assert_called_once() # type: ignore