From e390b1292cff12b0dd6db0e2603d065f998fbc24 Mon Sep 17 00:00:00 2001 From: Azide Date: Mon, 21 Mar 2022 00:31:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8E=9F=E6=9C=89=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BD=BF=E4=B9=8B=E7=AC=A6=E5=90=88=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_config_manager_abort.py | 9 ++++++--- tests/test_config_manager_add.py | 13 +++++++------ tests/utils.py | 12 +++++++++++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/tests/test_config_manager_abort.py b/tests/test_config_manager_abort.py index da307f4..a7d694c 100644 --- a/tests/test_config_manager_abort.py +++ b/tests/test_config_manager_abort.py @@ -67,6 +67,7 @@ async def test_abort_add_on_id(app: App): from nonebot_bison.config import Config from nonebot_bison.config_manager import add_sub_matcher, common_platform from nonebot_bison.platform import platform_manager + from nonebot_bison.platform.weibo import Weibo config = Config() config.user_target.truncate() @@ -103,7 +104,7 @@ async def test_abort_add_on_id(app: App): ctx.receive_event(bot, event_2) ctx.should_call_send( event_2, - Message(BotReply.add_reply_on_id), + Message(BotReply.add_reply_on_id(Weibo)), True, ) event_abort = fake_group_message_event( @@ -127,6 +128,7 @@ async def test_abort_add_on_cats(app: App): from nonebot_bison.config import Config from nonebot_bison.config_manager import add_sub_matcher, common_platform from nonebot_bison.platform import platform_manager + from nonebot_bison.platform.weibo import Weibo config = Config() config.user_target.truncate() @@ -167,7 +169,7 @@ async def test_abort_add_on_cats(app: App): ctx.receive_event(bot, event_2) ctx.should_call_send( event_2, - Message(BotReply.add_reply_on_id), + Message(BotReply.add_reply_on_id(Weibo)), True, ) event_3 = fake_group_message_event( @@ -207,6 +209,7 @@ async def test_abort_add_on_tag(app: App): from nonebot_bison.config import Config from nonebot_bison.config_manager import add_sub_matcher, common_platform from nonebot_bison.platform import platform_manager + from nonebot_bison.platform.weibo import Weibo config = Config() config.user_target.truncate() @@ -247,7 +250,7 @@ async def test_abort_add_on_tag(app: App): ctx.receive_event(bot, event_2) ctx.should_call_send( event_2, - Message(BotReply.add_reply_on_id), + Message(BotReply.add_reply_on_id(Weibo)), True, ) event_3 = fake_group_message_event( diff --git a/tests/test_config_manager_add.py b/tests/test_config_manager_add.py index 32f8b8c..cbb1764 100644 --- a/tests/test_config_manager_add.py +++ b/tests/test_config_manager_add.py @@ -64,6 +64,7 @@ async def test_add_with_target(app: App): from nonebot_bison.config import Config from nonebot_bison.config_manager import add_sub_matcher, common_platform from nonebot_bison.platform import platform_manager + from nonebot_bison.platform.weibo import Weibo config = Config() config.user_target.truncate() @@ -115,7 +116,7 @@ async def test_add_with_target(app: App): ctx.receive_event(bot, event_3) ctx.should_call_send( event_3, - Message(BotReply.add_reply_on_id), + Message(BotReply.add_reply_on_id(Weibo)), True, ) event_4_err = fake_group_message_event( @@ -181,6 +182,7 @@ async def test_add_with_target_no_cat(app: App): from nonebot_bison.config import Config from nonebot_bison.config_manager import add_sub_matcher, common_platform from nonebot_bison.platform import platform_manager + from nonebot_bison.platform.ncm_artist import NcmArtist config = Config() config.user_target.truncate() @@ -208,7 +210,7 @@ async def test_add_with_target_no_cat(app: App): ctx.receive_event(bot, event_3) ctx.should_call_send( event_3, - Message(BotReply.add_reply_on_id), + Message(BotReply.add_reply_on_id(NcmArtist)), True, ) event_4_ok = fake_group_message_event( @@ -332,6 +334,7 @@ async def test_add_with_get_id(app: App): from nonebot_bison.config import Config from nonebot_bison.config_manager import add_sub_matcher, common_platform from nonebot_bison.platform import platform_manager + from nonebot_bison.platform.weibo import Weibo config = Config() config.user_target.truncate() @@ -373,7 +376,7 @@ async def test_add_with_get_id(app: App): ctx.receive_event(bot, event_3) ctx.should_call_send( event_3, - Message(BotReply.add_reply_on_id), + Message(BotReply.add_reply_on_id(Weibo)), True, ) event_4_query = fake_group_message_event( @@ -462,9 +465,7 @@ async def test_add_with_target_parser(app: App): assert Bilibili.parse_target_promot ctx.should_call_send( event_3, - Message( - "1." + Bilibili.parse_target_promot + "\n2." + BotReply.add_reply_on_id - ), + Message(BotReply.add_reply_on_id(Bilibili)), True, ) event_4_err = fake_group_message_event( diff --git a/tests/utils.py b/tests/utils.py index 6de13c2..08bdbe2 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,3 +1,4 @@ +from ast import Str from typing import TYPE_CHECKING from typing_extensions import Literal @@ -130,9 +131,18 @@ class BotReply: def add_reply_subscribe_success(name): return "添加 {} 成功".format(name) + @staticmethod + def add_reply_on_id(platform: object) -> Str: + base_text = "请输入订阅用户的id\n查询id获取方法请回复:“查询”" + extra_text = ( + ("1." + platform.parse_target_promot + "\n2.") + if platform.parse_target_promot + else "" + ) + return extra_text + base_text + add_reply_on_id_input_error = "id输入错误" add_reply_on_target_parse_input_error = "不能从你的输入中提取出id,请检查你输入的内容是否符合预期" add_reply_on_platform_input_error = "平台输入错误" - add_reply_on_id = "请输入订阅用户的id\n查询id获取方法请回复:“查询”" add_reply_on_tags = '请输入要订阅的tag,订阅所有tag输入"全部标签"' add_reply_abort = "已中止订阅"