mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-16 11:00:54 +00:00
✨ add rule permission reflected operation support (#872)
Feature: 添加 Rule, Permission 反向位运算支持
This commit is contained in:
@ -20,6 +20,16 @@ async def test_rule(app: App):
|
||||
async def skipped() -> bool:
|
||||
raise SkippedException
|
||||
|
||||
def _is_eq(a: Rule, b: Rule) -> bool:
|
||||
return {d.call for d in a.checkers} == {d.call for d in b.checkers}
|
||||
|
||||
assert _is_eq(Rule(truthy) & None, Rule(truthy))
|
||||
assert _is_eq(Rule(truthy) & falsy, Rule(truthy, falsy))
|
||||
assert _is_eq(Rule(truthy) & Rule(falsy), Rule(truthy, falsy))
|
||||
|
||||
assert _is_eq(None & Rule(truthy), Rule(truthy))
|
||||
assert _is_eq(truthy & Rule(falsy), Rule(truthy, falsy))
|
||||
|
||||
event = make_fake_event()()
|
||||
|
||||
async with app.test_api() as ctx:
|
||||
|
Reference in New Issue
Block a user