add rule permission reflected operation support (#872)

Feature: 添加 Rule, Permission 反向位运算支持
This commit is contained in:
Ju4tCode
2022-03-17 21:11:37 +08:00
committed by GitHub
parent 06f8dde33c
commit 02de6fd266
5 changed files with 196 additions and 2 deletions

View File

@ -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: