fix: support AI commands in media captions
This commit is contained in:
@@ -8,6 +8,32 @@ from app.commands import CommandDispatcher, CommandRegistry
|
||||
|
||||
|
||||
class CommandDispatcherTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_command_in_media_caption_is_dispatched(self) -> None:
|
||||
registry = CommandRegistry()
|
||||
handler = AsyncMock()
|
||||
registry.command("photo", "Caption command")(handler)
|
||||
dispatcher = CommandDispatcher(registry)
|
||||
message = SimpleNamespace(
|
||||
text=None,
|
||||
caption=".photo argument",
|
||||
from_user=SimpleNamespace(id=123),
|
||||
reply_text=AsyncMock(),
|
||||
)
|
||||
account = SimpleNamespace(me=SimpleNamespace(id=123), acl_store=None)
|
||||
|
||||
handled = await dispatcher.dispatch(
|
||||
client=SimpleNamespace(),
|
||||
message=message,
|
||||
manager=SimpleNamespace(),
|
||||
account=account,
|
||||
)
|
||||
|
||||
self.assertTrue(handled)
|
||||
handler.assert_awaited_once()
|
||||
context = handler.await_args.args[0]
|
||||
self.assertEqual(context.args, "argument")
|
||||
self.assertEqual(context.raw_text, ".photo argument")
|
||||
|
||||
async def test_unknown_owner_command_is_silent(self) -> None:
|
||||
dispatcher = CommandDispatcher(CommandRegistry())
|
||||
message = SimpleNamespace(
|
||||
|
||||
Reference in New Issue
Block a user