"""Tests for the pricing table and cost calculation.""" from skill_eval_runner.pricing import DEFAULT_PRICING, calculate_cost, find_pricing def test_find_pricing_longest_substring_match() -> None: """A dated model name resolves to its base pricing entry.""" entry = find_pricing("claude-haiku-4-5-20251001", DEFAULT_PRICING) assert entry == DEFAULT_PRICING["claude-haiku-4"] def test_calculate_cost_known_model() -> None: """Cost sums input and output priced per million tokens.""" cost = calculate_cost("claude-sonnet-4-6", 1_000_000, 1_000_000) assert cost == 3.00 + 15.00 def test_calculate_cost_unknown_model_returns_none() -> None: """An unpriced model yields None rather than raising.""" assert calculate_cost("mystery-model-9", 100, 100) is None def test_calculate_cost_accepts_override_table() -> None: """A caller-supplied pricing table is honored over the default.""" table = {"mystery-model": {"input": 1.0, "output": 2.0}} cost = calculate_cost("mystery-model-9", 1_000_000, 1_000_000, table) assert cost == 3.0