(app: App)
| 258 | |
| 259 | @pytest.mark.anyio |
| 260 | async def test_event(app: App): |
| 261 | from plugins.param.param_event import ( |
| 262 | FooEvent, |
| 263 | event, |
| 264 | event_message, |
| 265 | event_plain_text, |
| 266 | event_to_me, |
| 267 | event_type, |
| 268 | generic_event, |
| 269 | generic_event_none, |
| 270 | legacy_event, |
| 271 | not_event, |
| 272 | not_legacy_event, |
| 273 | postpone_event, |
| 274 | sub_event, |
| 275 | union_event, |
| 276 | ) |
| 277 | |
| 278 | fake_message = FakeMessage("text") |
| 279 | fake_event = make_fake_event(_message=fake_message)() |
| 280 | fake_fooevent = make_fake_event(_base=FooEvent)() |
| 281 | |
| 282 | async with app.test_dependent(event, allow_types=[EventParam]) as ctx: |
| 283 | ctx.pass_params(event=fake_event) |
| 284 | ctx.should_return(fake_event) |
| 285 | |
| 286 | async with app.test_dependent(postpone_event, allow_types=[EventParam]) as ctx: |
| 287 | ctx.pass_params(event=fake_event) |
| 288 | ctx.should_return(fake_event) |
| 289 | |
| 290 | async with app.test_dependent(legacy_event, allow_types=[EventParam]) as ctx: |
| 291 | ctx.pass_params(event=fake_event) |
| 292 | ctx.should_return(fake_event) |
| 293 | |
| 294 | with pytest.raises(ValueError, match=UNKNOWN_PARAM): |
| 295 | app.test_dependent(not_legacy_event, allow_types=[EventParam]) |
| 296 | |
| 297 | async with app.test_dependent(sub_event, allow_types=[EventParam]) as ctx: |
| 298 | ctx.pass_params(event=fake_fooevent) |
| 299 | ctx.should_return(fake_fooevent) |
| 300 | |
| 301 | with pytest.raises((TypeMisMatch, BaseExceptionGroup)) as exc_info: |
| 302 | async with app.test_dependent(sub_event, allow_types=[EventParam]) as ctx: |
| 303 | ctx.pass_params(event=fake_event) |
| 304 | |
| 305 | if isinstance(exc_info.value, BaseExceptionGroup): |
| 306 | assert exc_info.group_contains(TypeMisMatch) |
| 307 | |
| 308 | async with app.test_dependent(union_event, allow_types=[EventParam]) as ctx: |
| 309 | ctx.pass_params(event=fake_fooevent) |
| 310 | ctx.should_return(fake_fooevent) |
| 311 | |
| 312 | async with app.test_dependent(generic_event, allow_types=[EventParam]) as ctx: |
| 313 | ctx.pass_params(event=fake_event) |
| 314 | ctx.should_return(fake_event) |
| 315 | |
| 316 | async with app.test_dependent(generic_event_none, allow_types=[EventParam]) as ctx: |
| 317 | ctx.pass_params(event=fake_event) |
nothing calls this directly
no test coverage detected