mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 01:40:15 +08:00
28 lines
729 B
Python
28 lines
729 B
Python
import pytest
|
|
|
|
from astrbot_sdk.testing import MockContext, MockMessageEvent
|
|
from main import HelloPlugin
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_hello_handler() -> None:
|
|
plugin = HelloPlugin()
|
|
ctx = MockContext(plugin_id="hello_plugin")
|
|
event = MockMessageEvent(text="/hello", context=ctx)
|
|
|
|
await plugin.hello(event, ctx)
|
|
|
|
assert event.replies == ["Hello, World!"]
|
|
ctx.platform.assert_sent("Hello, World!")
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_about_handler() -> None:
|
|
plugin = HelloPlugin()
|
|
ctx = MockContext(plugin_id="hello_plugin")
|
|
event = MockMessageEvent(text="/about", context=ctx)
|
|
|
|
await plugin.about(event, ctx)
|
|
|
|
assert any("hello_plugin" in reply for reply in event.replies)
|