mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-16 11:00:54 +00:00
🐛 fix nested user permission update (#1208)
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user