test(config): fix cap-at-12 test to actually exercise the cap

This commit is contained in:
claude
2026-08-22 00:19:25 +00:00
parent 0f7903377a
commit 9dae850887
+15 -5
View File
@@ -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"]