test_serve_runs_the_background_loop_beside_the_transport¶
Tests › tests/test_background_indexing.py
What this test is for
Why it exists
THE WIRING. `keep_current` can be perfect and never run; this drives `serve` with a stand-in transport that returns only once a background pass has happened, and with the loop disabled asserts no pass happens at all.
Given
- —
When
_mcp, state = build_server(st.TargetRegistry(tmp_path / "state"))passes: list[int] = []ran = anyio.Event()
7 more
async def _pass() -> list[str]: passes.append(1) ran.set() return []state.refresh_touched = _passasync def _until_a_pass(_mcp: object) -> None: await ran.wait()with anyio.fail_after(5): await serve(_mcp, state, 0.01, _until_a_pass)passes.clear()async def _immediately(_mcp: object) -> None: await anyio.sleep(0.05)await serve(_mcp, state, 0, _immediately)
Then
- ✓ passes holds
- ✓ passes equals []
What it exercises
The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.
Build, refresh and check the index · 9 of 153 steps
… 21 earlier steps
… 118 later steps
1 more
- clew-mcp — `main` (clew/mcp_server/server.py) · 8 of 17 steps
tests/test_background_indexing.py:258 · its file's page
What it checks (2)
assert passes, "an enabled loop must run beside the transport"not attributedassert passes == [], "interval 0 disables the loop"not attributed
Where the product reaches it
main→build_server(flow)
Call flow
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 8 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-INDEX-006 measured
- REQ-DDB-MCP-001 measured
- REQ-DDB-MCP-003 measured
- REQ-DDB-MCP-004 measured
- REQ-DDB-WIKI-032 measured
- REQ-DDB-WIKI-033 measured
- REQ-DDB-WIKI-034 measured
- REQ-DDB-WIKI-054 measured