test_an_edited_yaml_document_is_parsed_again

Tests › tests/test_datamodel.py

passed Passed in the packaged run.

What this test is for

Why it exists

THE CONTROL. Content is the key, so an edit must re-derive — a cache that served a stale key list would put keys in the catalog that the repository no longer declares, and the declared-vs-observed diagnostic reads that as a fact about the code.

Given

  1. repo = tmp_path / "repo"
  2. (repo / "conf").mkdir(parents=True)
13 more
  1. listed = repo / "conf" / "keys.yaml"
  2. listed.write_text("- ALPHA_KEY\n", encoding="utf-8")
  3. cache_path = tmp_path / "clew.db.idxcache"
  4. cache = IndexCache(cache_path, repo)
  5. discover(repo, (), cache=cache)
  6. cache.commit()
  7. loads = {"n": 0}
  8. original = yaml.safe_load
  9. def counting(*args, **kwargs): # noqa: ANN002, ANN003, ANN202 loads["n"] += 1 return original(*args, **kwargs)
  10. monkeypatch.setattr(yaml, "safe_load", counting)
  11. listed.write_text("- ALPHA_KEY\n- GAMMA_KEY\n", encoding="utf-8")
  12. cache = IndexCache(cache_path, repo)
  13. discover(repo, (), cache=cache)
→

When

  1. —
→

Then

  1. ✓ loads["n"] is greater than 0

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.

thread `clew-first-build-` — `_first_build_worker` (clew/mcp_server/server.py) · 4 of 142 steps

… 8 earlier steps

thread startthread startthread startthread startclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyother filesother filesother filesother filesopt (line 845)optloop (line 1239)loopopt (line 847)optloop (line 746)loop_first_build_worker9. whole_repo_scope → list9list10. whole_repo_scope → nested_repo_roots10nested_repo_roots11. nested_repo_roots → _nested_repos_under11_nested_repos_under▶ test enters12–14. _nested_repos_under → _warn_unwalkable12_warn_unwalkable +2 more15. nested_repo_roots → _nested_repos_under15_nested_repos_under16. whole_repo_scope → _gitignored_paths16_gitignored_paths

… 126 later steps

2 more

tests/test_datamodel.py:1005 · its file's page

What it checks (1)

  1. assert loads["n"] > 0, "an edited document must be read again, not served from the cache" 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.

Also reaches 4 requirements

Its run touches their code; that is reach, not proof.