test_build_or_refresh_skips_current_db_and_activates¶
Tests › tests/test_mcp_server.py
What this test is for
Why it exists
When the target's db is already current, no build runs — but tier-1 is still activated and the client is notified.
Verifies REQ-DDB-QUERY-006 REQ-DDB-QUERY-008 REQ-DDB-QUERY-009
Given
mcp, state = serverrepo = tmp_path / "repo"
8 more
repo.mkdir()target = state.registry.register(str(repo))state.active = targetPath(target.db_path).write_bytes(rich_db.read_bytes())def _fail_build(*_args, **_kwargs): raise AssertionError("a current db must not be rebuilt without force=True")monkeypatch.setattr(state, "_run_build", _fail_build)ctx = _FakeCtx()result = await state.build_or_refresh(ctx)
When
- —
Then
- ✓ result["ok"] is True
- ✓ result["built"] is False
- ✓ set(result["tools"]) equals set(TIER1_TOOLS)
- ✓ ctx.session.notifications equals 1
- ✓ set(TIER1_TOOLS) is at most await _names(mcp)
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 · 50 of 153 steps
… 2 earlier steps
… 9 steps between
… 62 steps between
… 8 later steps
5 more
- thread `clew-first-build-` — `_first_build_worker` (clew/mcp_server/server.py) · 31 of 142 steps
- `main` (scripts/stage_probe.py) · 30 of 37 steps
- clew-mcp — `main` (clew/mcp_server/server.py) · 4 of 17 steps
- clew — `main` (clew/cli.py) · 1 of 400 steps
- `main` (scripts/incremental_probe.py) · 1 of 3 steps
tests/test_mcp_server.py:643 · its file's page
What it checks (5)
assert result["ok"] is Truenot attributedassert result["built"] is Falsenot attributedassert set(result["tools"]) == set(TIER1_TOOLS)not attributedassert ctx.session.notifications == 1not attributedassert set(TIER1_TOOLS) <= await _names(mcp)not attributed
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.
Requirements it verifies (3)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-QUERY-006 | catalog | unknown |
| REQ-DDB-QUERY-008 | catalog | unknown |
| REQ-DDB-QUERY-009 | catalog | unknown |
Also reaches 11 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-CONFIG-001 measured
- REQ-DDB-CONFIG-006 measured
- REQ-DDB-CONFIG-007 measured
- REQ-DDB-CONFIG-008 measured
- REQ-DDB-INDEX-003 measured
- REQ-DDB-MCP-001 measured
- REQ-DDB-MCP-002 measured
- REQ-DDB-MCP-003 measured
- REQ-DDB-MCP-004 measured
- REQ-DDB-PIPE-005 measured
- REQ-DDB-WIKI-054 measured