Skip to content

10/11 Make CAT tests hermetic (no live API), ~13 min → ~15 s - #644

Open
mcfrank wants to merge 1 commit into
phase8-security2from
phase9-cat-tests
Open

10/11 Make CAT tests hermetic (no live API), ~13 min → ~15 s#644
mcfrank wants to merge 1 commit into
phase8-security2from
phase9-cat-tests

Conversation

@mcfrank

@mcfrank mcfrank commented Jul 10, 2026

Copy link
Copy Markdown
Member

Continues the stack (targets the security-round-2 branch; merge after #643). Addresses #628.

The five language CAT tests replayed a recorded item/response/theta sequence but reached the live production R API for each next item — so the suite needed a network connection and was coupled to whatever parameters are deployed. That coupling already broke the Spanish sequence test (deployed API drifted to pre-rename item names), which had been skipped.

  • New cat_api_mock helper patches the view's cdi_cat_api to replay the recorded sequence (and answer startItem from the start-items CSV). The recording is the ground truth the API is meant to return, so this exercises the full view flow — render, store answer, advance, stop, persist theta — with no network.
  • The live API rounded theta to 4 decimals; the mock matches so the est_theta assertions hold. Each class is pinned to CAT_ENGINE=remote.
  • Restores the previously-skipped test_spanish_seq_1, and renames the Dutch class's copy-pasted test_spanish_* methods to test_dutch_*.

Result

  • CAT suite: ~13 min → ~15 s, no network.
  • Proven hermetic: the suite passes with CAT_API_URL pointed at a dead address (127.0.0.1:1) — a real call would fail connection-refused.
  • 15 tests OK.

🤖 Generated with Claude Code

… live API

The five language CAT tests (english/french/dutch/japanese/spanish)
replayed a recorded item/response/theta sequence but reached the live
production R API to obtain each next item — so the suite required a
network connection and was coupled to whatever parameters happen to be
deployed. That coupling is exactly what had already broken the Spanish
sequence test (the deployed API drifted to pre-rename item names), which
was skipped as a result.

A new cat_api_mock helper patches the view's cdi_cat_api to replay the
recorded sequence (and to answer startItem from the start-items CSV) —
the recording is the ground truth the API is meant to return, so this
exercises the full view flow (render, store answer, advance, stop,
persist theta) with no network. The theta the live API returned was
rounded to 4 decimals; the mock matches that so the est_theta assertions
hold. Each class is pinned to CAT_ENGINE=remote so it deterministically
tests the remote view path.

Result: the CAT suite drops from ~13 min (network-bound) to ~15 s, the
previously-skipped Spanish sequence test is restored, and the tests pass
even with CAT_API_URL pointed at a dead address (proving no live call).
Also renames the Dutch class's copy-pasted test_spanish_* methods to
test_dutch_*.

Addresses #628.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant