mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-06-23 14:16:52 +08:00
♻️ 迁移到 uv 并重写 Dockerfile (#667)
Co-authored-by: BalconyJH <balconyjh@gmail.com> Co-authored-by: suyiiyii <suyiiyii@gmail.com>
This commit is contained in:
@@ -4,31 +4,7 @@ from nonebug.app import App
|
||||
import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from tests.utils import BotReply, fake_admin_user, fake_private_message_event, fake_superuser
|
||||
|
||||
|
||||
async def test_add_cookie_rule(app: App, mocker: MockerFixture):
|
||||
from nonebot.adapters.onebot.v11.bot import Bot
|
||||
from nonebot.adapters.onebot.v11.message import Message
|
||||
|
||||
from nonebot_bison.plugin_config import plugin_config
|
||||
from nonebot_bison.sub_manager import add_cookie_matcher
|
||||
|
||||
mocker.patch.object(plugin_config, "bison_to_me", True)
|
||||
|
||||
async with app.test_matcher(add_cookie_matcher) as ctx:
|
||||
bot = ctx.create_bot(base=Bot)
|
||||
event = fake_private_message_event(message=Message("添加cookie"), sender=fake_superuser)
|
||||
ctx.receive_event(bot, event)
|
||||
ctx.should_pass_rule()
|
||||
ctx.should_pass_permission()
|
||||
|
||||
async with app.test_matcher(add_cookie_matcher) as ctx:
|
||||
bot = ctx.create_bot(base=Bot)
|
||||
event = fake_private_message_event(message=Message("添加cookie"), sender=fake_admin_user)
|
||||
ctx.receive_event(bot, event)
|
||||
ctx.should_not_pass_rule()
|
||||
ctx.should_pass_permission()
|
||||
from tests.utils import BotReply, fake_private_message_event, fake_superuser
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("_clear_db")
|
||||
|
||||
@@ -42,4 +42,5 @@ async def test_without_permission(app: App):
|
||||
True,
|
||||
)
|
||||
ctx.should_pass_rule()
|
||||
ctx.should_pass_permission()
|
||||
ctx.should_pass_permission(no_permission_matcher)
|
||||
ctx.should_not_pass_permission(add_sub_matcher)
|
||||
|
||||
@@ -19,6 +19,6 @@ async def test_http_error(app: App):
|
||||
"https://example.com Headers({'host': 'example.com', 'accept': '*/*', 'accept-encoding': 'gzip, deflate',"
|
||||
" 'connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
||||
" (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0'}) | [403] Headers({'content-length': '"
|
||||
"15', 'content-type':"
|
||||
' \'application/json\'}) {"error": "gg"}'
|
||||
"14', 'content-type':"
|
||||
' \'application/json\'}) {"error":"gg"}'
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user