wiki control inits the structure and reports status.
(tmp_path)
| 661 | |
| 662 | @pytest.mark.asyncio |
| 663 | async def test_control_wiki(tmp_path): |
| 664 | """wiki control inits the structure and reports status.""" |
| 665 | from src.tool_system.registry import ToolRegistry |
| 666 | |
| 667 | with contextlib.ExitStack() as stack: |
| 668 | for p in _patches(_TextProvider, ToolRegistry([])): |
| 669 | stack.enter_context(p) |
| 670 | spawn = make_spawn_agent(AgentServerConfig(permission_mode="default")) |
| 671 | handle = await spawn("ds_test", str(tmp_path), None) |
| 672 | gen = handle.messages_from_agent() |
| 673 | try: |
| 674 | init = await asyncio.wait_for(gen.__anext__(), timeout=5) |
| 675 | assert init["subtype"] == "init" |
| 676 | |
| 677 | async def _reply_for(rid, req): |
| 678 | await handle.send_to_agent({"type": "control_request", "request_id": rid, "request": req}) |
| 679 | for _ in range(12): |
| 680 | msg = await asyncio.wait_for(gen.__anext__(), timeout=5) |
| 681 | if msg.get("type") == "control_response" and msg["response"].get("request_id") == rid: |
| 682 | return msg["response"]["response"] |
| 683 | raise AssertionError(f"no reply for {rid}") |
| 684 | |
| 685 | before = await _reply_for("w0", {"subtype": "wiki", "action": "status"}) |
| 686 | assert before["initialized"] is False |
| 687 | |
| 688 | ini = await _reply_for("w1", {"subtype": "wiki", "action": "init"}) |
| 689 | assert ini["ok"] is True and len(ini["created_files"]) >= 4 |
| 690 | |
| 691 | after = await _reply_for("w2", {"subtype": "wiki", "action": "status"}) |
| 692 | assert after["initialized"] is True and after["page_count"] == 1 |
| 693 | finally: |
| 694 | await handle.shutdown() |
| 695 | with contextlib.suppress(Exception): |
| 696 | await gen.aclose() |
| 697 | |
| 698 | |
| 699 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected