MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / test_control_knowledge

Function test_control_knowledge

tests/server/test_agent_server_e2e.py:626–659  ·  view source on GitHub ↗

knowledge control returns stats and toggles enable/disable.

(tmp_path)

Source from the content-addressed store, hash-verified

624
625@pytest.mark.asyncio
626async def test_control_knowledge(tmp_path):
627 """knowledge control returns stats and toggles enable/disable."""
628 from src.tool_system.registry import ToolRegistry
629
630 with contextlib.ExitStack() as stack:
631 for p in _patches(_TextProvider, ToolRegistry([])):
632 stack.enter_context(p)
633 spawn = make_spawn_agent(AgentServerConfig(permission_mode="default"))
634 handle = await spawn("ds_test", str(tmp_path), None)
635 gen = handle.messages_from_agent()
636 try:
637 init = await asyncio.wait_for(gen.__anext__(), timeout=5)
638 assert init["subtype"] == "init"
639
640 async def _reply_for(rid, req):
641 await handle.send_to_agent({"type": "control_request", "request_id": rid, "request": req})
642 for _ in range(12):
643 msg = await asyncio.wait_for(gen.__anext__(), timeout=5)
644 if msg.get("type") == "control_response" and msg["response"].get("request_id") == rid:
645 return msg["response"]["response"]
646 raise AssertionError(f"no reply for {rid}")
647
648 st = await _reply_for("k1", {"subtype": "knowledge", "action": "status"})
649 assert st["ok"] is True and "total" in st["stats"] and st["enabled"] is True
650
651 off = await _reply_for("k2", {"subtype": "knowledge", "action": "disable"})
652 assert off["enabled"] is False
653
654 lst = await _reply_for("k3", {"subtype": "knowledge", "action": "list"})
655 assert lst["ok"] is True and isinstance(lst["entities"], list)
656 finally:
657 await handle.shutdown()
658 with contextlib.suppress(Exception):
659 await gen.aclose()
660
661
662@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 9

ToolRegistryClass · 0.90
make_spawn_agentFunction · 0.90
AgentServerConfigClass · 0.90
_patchesFunction · 0.85
_reply_forFunction · 0.85
__anext__Method · 0.80
spawnFunction · 0.70
shutdownMethod · 0.45
acloseMethod · 0.45

Tested by

no test coverage detected