test(config): fix cap-at-12 test to actually exercise the cap
This commit is contained in:
@@ -1805,9 +1805,19 @@ def test_parse_repo_config_compare_against_drops_unknown_keys(capfd):
|
|||||||
assert "bogus-1" in captured.err
|
assert "bogus-1" in captured.err
|
||||||
|
|
||||||
|
|
||||||
def test_parse_repo_config_compare_against_caps_at_12():
|
def test_parse_repo_config_compare_against_caps_at_12(monkeypatch):
|
||||||
raw_keys = ["claude-sonnet-5"] + [f"bogus-{i}" for i in range(20)]
|
"""13+ valid keys must be truncated to the first 12; invalid keys are
|
||||||
cfg = parse_repo_config(json.dumps({"compare_against": raw_keys}))
|
dropped and do not count. Inject a 13th PRICES entry via monkeypatch so
|
||||||
# Only claude-sonnet-5 is valid; rest dropped; net result is 1 entry.
|
the [:12] cap actually fires (cost_model.PRICES has exactly 12 keys
|
||||||
assert len(cfg["compare_against"]) == 1
|
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"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user