From 9dae850887d6c6d4e1b7ff59532a20e1507e91cb Mon Sep 17 00:00:00 2001 From: claude Date: Sat, 22 Aug 2026 00:19:25 +0000 Subject: [PATCH] test(config): fix cap-at-12 test to actually exercise the cap --- tests/pilot/test_ai_review.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/pilot/test_ai_review.py b/tests/pilot/test_ai_review.py index c7490f7..98230ce 100644 --- a/tests/pilot/test_ai_review.py +++ b/tests/pilot/test_ai_review.py @@ -1805,9 +1805,19 @@ def test_parse_repo_config_compare_against_drops_unknown_keys(capfd): assert "bogus-1" in captured.err -def test_parse_repo_config_compare_against_caps_at_12(): - raw_keys = ["claude-sonnet-5"] + [f"bogus-{i}" for i in range(20)] - cfg = parse_repo_config(json.dumps({"compare_against": raw_keys})) - # Only claude-sonnet-5 is valid; rest dropped; net result is 1 entry. - assert len(cfg["compare_against"]) == 1 +def test_parse_repo_config_compare_against_caps_at_12(monkeypatch): + """13+ valid keys must be truncated to the first 12; invalid keys are + dropped and do not count. Inject a 13th PRICES entry via monkeypatch so + the [:12] cap actually fires (cost_model.PRICES has exactly 12 keys + today, which would otherwise make the cap a no-op).""" + import cost_model as cm + monkeypatch.setitem( + cm.PRICES, "fake-model-13", cm.Price("Fake", 1.00, 2.00, 1.00, 0.10)) + valid = list(cm.PRICES) # 13 unique keys (12 real + 1 test-only) + raw = valid + ["bogus-extra"] # 13 valid + 1 invalid + cfg = parse_repo_config(json.dumps({"compare_against": raw})) + assert len(cfg["compare_against"]) == 12 + assert cfg["compare_against"] == valid[:12] + assert "fake-model-13" not in cfg["compare_against"] + assert "bogus-extra" not in cfg["compare_against"]