summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_plugin_chat.py84
-rw-r--r--test/test_plugin_code_runner.py10
-rw-r--r--test/test_plugin_help.py23
-rw-r--r--test/test_plugin_kimo.py43
4 files changed, 62 insertions, 98 deletions
diff --git a/test/test_plugin_chat.py b/test/test_plugin_chat.py
deleted file mode 100644
index e04f1d3..0000000
--- a/test/test_plugin_chat.py
+++ /dev/null
@@ -1,84 +0,0 @@
-import pytest
-from nonebug import App
-from nonebot.adapters.onebot.v11 import MessageSegment
-
-from .utils import make_fake_message, make_fake_event
-
-
-async def test_chat(app: App):
- from ATRI.plugins.chat import chat
-
- Message = make_fake_message()
-
- async with app.test_matcher(chat) as ctx:
- bot = ctx.create_bot()
-
- msg = Message("爱你")
- event = make_fake_event(_message=msg, _to_me=True)()
-
- ctx.receive_event(bot, event)
- ctx.should_call_send(event, "是…是嘛(脸红)呐,其实咱也……", True)
-
-
-async def test_my_name_is(app: App):
- from ATRI.plugins.chat import my_name_is
-
- Message = make_fake_message()
-
- async with app.test_matcher(my_name_is) as ctx:
- bot = ctx.create_bot()
-
- msg = Message("叫我")
- event = make_fake_event(_message=msg, _to_me=True)()
-
- ctx.receive_event(bot, event)
- ctx.should_call_send(event, "欧尼酱想让咱如何称呼呢!0w0", True)
-
- msg = Message("欧尼酱")
- event = make_fake_event(_message=msg)()
-
- ctx.receive_event(bot, event)
- ctx.should_call_send(event, "好~w 那咱以后就称呼你为欧尼酱!", True)
-
-
-async def test_say(app: App):
- from ATRI.plugins.chat import say
-
- Message = make_fake_message()
-
- async with app.test_matcher(say) as ctx:
- bot = ctx.create_bot()
-
- msg = Message("说")
- event = make_fake_event(_message=msg, _to_me=True)()
-
- ctx.receive_event(bot, event)
- ctx.should_call_send(event, "想要咱复读啥呢...", True)
-
- msg = Message("nya~")
- event = make_fake_event(_message=msg)()
-
- ctx.receive_event(bot, event)
- ctx.should_call_send(event, "nya~", True)
-
- async with app.test_matcher(say) as ctx:
- bot = ctx.create_bot()
-
- msg = Message("说")
- event = make_fake_event(_message=msg, _to_me=True)()
-
- ctx.receive_event(bot, event)
- ctx.should_call_send(event, "想要咱复读啥呢...", True)
-
- msg = Message(
- MessageSegment.image(
- "https://cdn.jsdelivr.net/gh/Kyomotoi/CDN@master/noting/88674944_p0.png"
- )
- )
- event = make_fake_event(_message=msg, _to_me=True)()
-
- ctx.receive_event(bot, event)
- ctx.should_call_send(event, "不要...", True)
diff --git a/test/test_plugin_code_runner.py b/test/test_plugin_code_runner.py
index 584ebb0..ec9eb2d 100644
--- a/test/test_plugin_code_runner.py
+++ b/test/test_plugin_code_runner.py
@@ -17,12 +17,12 @@ async def test_code_runner(app: App):
event = make_fake_event(_message=msg)()
ctx.receive_event(bot, event)
- ctx.should_call_send(event, "请键入 /code help 以获取帮助~!", True)
+ ctx.should_call_send(event, "请键入 /code.help 以获取帮助~!", True)
async with app.test_matcher(code_runner) as ctx:
bot = ctx.create_bot()
- msg = Message("/code help")
+ msg = Message("/code.help")
event = make_fake_event(_message=msg)()
ctx.receive_event(bot, event)
@@ -34,14 +34,14 @@ async def test_code_runner(app: App):
For example:
/code python
print('hello world')
- """,
+ """.strip(),
True,
)
async with app.test_matcher(code_runner) as ctx:
bot = ctx.create_bot()
- msg = Message("/code list")
+ msg = Message("/code.list")
event = make_fake_event(_message=msg)()
ctx.receive_event(bot, event)
@@ -56,7 +56,7 @@ async def test_code_runner(app: App):
julia, kotlin, lua, perl,
php, python, ruby, rust,
scala, swift, typescript
- """,
+ """.strip(),
True,
)
diff --git a/test/test_plugin_help.py b/test/test_plugin_help.py
index 82a0467..3d975ac 100644
--- a/test/test_plugin_help.py
+++ b/test/test_plugin_help.py
@@ -6,11 +6,11 @@ from .utils import make_fake_message, make_fake_event
@pytest.mark.asyncio
async def test_main_help(app: App):
- from ATRI.plugins.help import main_help
+ from ATRI.plugins.help import menu
Message = make_fake_message()
- async with app.test_matcher(main_help) as ctx:
+ async with app.test_matcher(menu) as ctx:
bot = ctx.create_bot()
msg = Message("菜单")
@@ -25,7 +25,7 @@ async def test_main_help(app: App):
服务列表 -以查看所有可用服务
帮助 [服务] -以查看对应服务帮助
Tip: 均需要at触发。@bot 菜单 以打开此页面
- """,
+ """.strip(),
True,
)
@@ -34,7 +34,7 @@ async def test_main_help(app: App):
async def test_about_me(app: App):
from ATRI import __version__
from ATRI.config import BotSelfConfig
- from ATRI.plugins.help import about_me
+ from ATRI.plugins.help import about
temp_list = list()
for i in BotSelfConfig.nickname:
@@ -43,7 +43,7 @@ async def test_about_me(app: App):
Message = make_fake_message()
- async with app.test_matcher(about_me) as ctx:
+ async with app.test_matcher(about) as ctx:
bot = ctx.create_bot()
msg = Message("关于")
@@ -57,8 +57,9 @@ async def test_about_me(app: App):
可以称呼咱:{nickname}
咱的型号是:{__version__}
想进一步了解:
- https://github.com/Kyomotoi/ATRI
- """,
+ atri.kyomotoi.moe
+ 进不去: project-atri-docs.vercel.app
+ """.strip(),
True,
)
@@ -87,7 +88,10 @@ async def test_service_list(app: App):
]
)
table = tabulate(
- services, headers=["服务名称", "开启状态", "仅支持管理员"], tablefmt="plain", showindex=True
+ services,
+ headers=["服务名称", "开启状态(全局)", "仅支持管理员"],
+ tablefmt="plain",
+ showindex=True,
)
output = f"咱搭载了以下服务~\n{table}\n@bot 帮助 [服务] -以查看对应服务帮助"
@@ -139,7 +143,8 @@ async def test_service_info(app: App):
服务名:状态
说明:检查咱自身状态
可用命令:
- /ping、/status
+ /ping
+ /status
是否全局启用:True
Tip: @bot 帮助 [服务] [命令] 以查看对应命令详细信息
""",
diff --git a/test/test_plugin_kimo.py b/test/test_plugin_kimo.py
new file mode 100644
index 0000000..ad6ff0b
--- /dev/null
+++ b/test/test_plugin_kimo.py
@@ -0,0 +1,43 @@
+import pytest
+from nonebug import App
+from nonebot.adapters.onebot.v11 import MessageSegment
+
+from .utils import make_fake_message, make_fake_event
+
+
+async def test_chat(app: App):
+ from ATRI.plugins.kimo import kimo
+
+ Message = make_fake_message()
+
+ async with app.test_matcher(kimo) as ctx:
+ bot = ctx.create_bot()
+
+ msg = Message("爱你")
+ event = make_fake_event(_message=msg, _to_me=True)()
+
+ ctx.receive_event(bot, event)
+ ctx.should_call_send(event, "是…是嘛(脸红)呐,其实咱也……", True)
+
+
+async def test_my_name_is(app: App):
+ from ATRI.plugins.kimo import my_name_is
+
+ Message = make_fake_message()
+
+ async with app.test_matcher(my_name_is) as ctx:
+ bot = ctx.create_bot()
+
+ msg = Message("叫我")
+ event = make_fake_event(_message=msg, _to_me=True)()
+
+ ctx.receive_event(bot, event)
+ ctx.should_call_send(event, "欧尼酱想让咱如何称呼呢!0w0", True)
+
+ msg = Message("欧尼酱")
+ event = make_fake_event(_message=msg)()
+
+ ctx.receive_event(bot, event)
+ ctx.should_call_send(event, "好~w 那咱以后就称呼你为欧尼酱!", True)