(app: App)
| 50 | |
| 51 | @pytest.mark.anyio |
| 52 | async def test_rule(app: App): |
| 53 | async def falsy(): |
| 54 | return False |
| 55 | |
| 56 | async def truthy(): |
| 57 | return True |
| 58 | |
| 59 | async def skipped() -> bool: |
| 60 | raise SkippedException |
| 61 | |
| 62 | def _is_eq(a: Rule, b: Rule) -> bool: |
| 63 | return {d.call for d in a.checkers} == {d.call for d in b.checkers} |
| 64 | |
| 65 | assert _is_eq(Rule(truthy) & None, Rule(truthy)) |
| 66 | assert _is_eq(Rule(truthy) & falsy, Rule(truthy, falsy)) |
| 67 | assert _is_eq(Rule(truthy) & Rule(falsy), Rule(truthy, falsy)) |
| 68 | |
| 69 | assert _is_eq(None & Rule(truthy), Rule(truthy)) |
| 70 | assert _is_eq(truthy & Rule(falsy), Rule(truthy, falsy)) |
| 71 | |
| 72 | event = make_fake_event()() |
| 73 | |
| 74 | async with app.test_api() as ctx: |
| 75 | bot = ctx.create_bot() |
| 76 | assert await Rule(falsy)(bot, event, {}) is False |
| 77 | assert await Rule(truthy)(bot, event, {}) is True |
| 78 | assert await Rule(skipped)(bot, event, {}) is False |
| 79 | assert await Rule(truthy, falsy)(bot, event, {}) is False |
| 80 | assert await Rule(truthy, skipped)(bot, event, {}) is False |
| 81 | |
| 82 | |
| 83 | @pytest.mark.anyio |
nothing calls this directly
no test coverage detected