(app: App)
| 670 | |
| 671 | @pytest.mark.anyio |
| 672 | async def test_arg(app: App): |
| 673 | from plugins.param.param_arg import ( |
| 674 | annotated_arg, |
| 675 | annotated_arg_plain_text, |
| 676 | annotated_arg_prompt_result, |
| 677 | annotated_arg_str, |
| 678 | annotated_multi_arg, |
| 679 | annotated_prior_arg, |
| 680 | arg, |
| 681 | arg_plain_text, |
| 682 | arg_str, |
| 683 | ) |
| 684 | |
| 685 | matcher = Matcher() |
| 686 | event = make_fake_event()() |
| 687 | message = FakeMessage("text") |
| 688 | matcher.set_arg("key", message) |
| 689 | |
| 690 | async with app.test_dependent(arg, allow_types=[ArgParam]) as ctx: |
| 691 | ctx.pass_params(matcher=matcher) |
| 692 | ctx.should_return(message) |
| 693 | |
| 694 | async with app.test_dependent(arg_str, allow_types=[ArgParam]) as ctx: |
| 695 | ctx.pass_params(matcher=matcher) |
| 696 | ctx.should_return(str(message)) |
| 697 | |
| 698 | async with app.test_dependent(arg_plain_text, allow_types=[ArgParam]) as ctx: |
| 699 | ctx.pass_params(matcher=matcher) |
| 700 | ctx.should_return(message.extract_plain_text()) |
| 701 | |
| 702 | async with app.test_dependent(annotated_arg, allow_types=[ArgParam]) as ctx: |
| 703 | ctx.pass_params(matcher=matcher) |
| 704 | ctx.should_return(message) |
| 705 | |
| 706 | async with app.test_dependent(annotated_arg_str, allow_types=[ArgParam]) as ctx: |
| 707 | ctx.pass_params(matcher=matcher) |
| 708 | ctx.should_return(str(message)) |
| 709 | |
| 710 | async with app.test_dependent( |
| 711 | annotated_arg_plain_text, allow_types=[ArgParam] |
| 712 | ) as ctx: |
| 713 | ctx.pass_params(matcher=matcher) |
| 714 | ctx.should_return(message.extract_plain_text()) |
| 715 | |
| 716 | matcher.set_target(ARG_KEY.format(key="key"), cache=False) |
| 717 | |
| 718 | async with app.test_api() as ctx: |
| 719 | bot = ctx.create_bot() |
| 720 | ctx.should_call_send(event, "test", result="arg", bot=bot) |
| 721 | with matcher.ensure_context(bot, event): |
| 722 | with suppress(RejectedException): |
| 723 | await matcher.reject("test") |
| 724 | |
| 725 | async with app.test_dependent( |
| 726 | annotated_arg_prompt_result, allow_types=[ArgParam] |
| 727 | ) as ctx: |
| 728 | ctx.pass_params(matcher=matcher) |
| 729 | ctx.should_return("arg") |
nothing calls this directly
no test coverage detected