🐛 fix nested user permission update (#1208)

This commit is contained in:
Ju4tCode
2022-09-01 10:41:43 +08:00
committed by GitHub
parent f150a9ee89
commit cd30be21ba
4 changed files with 61 additions and 10 deletions

View File

@ -1,3 +1,5 @@
from typing import Tuple
import pytest
from nonebug import App
@ -145,7 +147,7 @@ async def test_metaevent(
("notice", "test", False),
],
)
async def test_startswith(
async def test_superuser(
app: App,
type: str,
user_id: str,
@ -163,3 +165,28 @@ async def test_startswith(
async with app.test_api() as ctx:
bot = ctx.create_bot()
assert await dependent(bot=bot, event=event) == expected
@pytest.mark.asyncio
@pytest.mark.parametrize(
"session_ids,session_id,expected",
[
(("user", "foo"), "user", True),
(("user", "foo"), "bar", False),
],
)
async def test_user(
app: App, session_ids: Tuple[str, ...], session_id: str, expected: bool
):
from nonebot.permission import USER, User
dependent = list(USER(*session_ids).checkers)[0]
checker = dependent.call
assert isinstance(checker, User)
event = make_fake_event(_session_id=session_id)()
async with app.test_api() as ctx:
bot = ctx.create_bot()
assert await dependent(bot=bot, event=event) == expected