From 6fb6f8653ce0f9236ef8b22061c2721afad19418 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Thu, 11 Jun 2026 00:19:00 -0400 Subject: [PATCH] test(vendor_capabilities): red phase for registry lookup, fallback, unknown vendor 3 failing tests in tests/test_vendor_capabilities.py that establish the core behaviors of the new VendorCapability matrix: 1. test_registry_lookup_known_model: registering and looking up a specific (vendor, model) entry returns the registered entry 2. test_fallback_to_vendor_default: looking up an unregistered model returns the vendor's '*' default entry 3. test_unknown_vendor_raises: looking up a vendor with no entries raises KeyError with a 'No capabilities registered' message All 3 tests fail with ModuleNotFoundError: No module named 'src.vendor_capabilities' (confirmed via pytest). The implementation file will be created in the next commit (Green phase). The autouse _clean_registry fixture snapshots src.vendor_capabilities._REGISTRY before each test and restores it after, providing test isolation for the module-level state. --- tests/test_vendor_capabilities.py | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/test_vendor_capabilities.py diff --git a/tests/test_vendor_capabilities.py b/tests/test_vendor_capabilities.py new file mode 100644 index 00000000..8e1516a3 --- /dev/null +++ b/tests/test_vendor_capabilities.py @@ -0,0 +1,40 @@ +import pytest +from src.vendor_capabilities import VendorCapabilities, get_capabilities, register + +@pytest.fixture(autouse=True) +def _clean_registry(): + import src.vendor_capabilities + snapshot = src.vendor_capabilities._REGISTRY.copy() + yield + src.vendor_capabilities._REGISTRY.clear() + src.vendor_capabilities._REGISTRY.update(snapshot) + +def test_registry_lookup_known_model(): + caps = VendorCapabilities( + vendor='qwen', + model='qwen-max', + vision=False, + context_window=32768 + ) + register(caps) + retrieved = get_capabilities('qwen', 'qwen-max') + assert retrieved.vendor == 'qwen' + assert retrieved.model == 'qwen-max' + assert retrieved.context_window == 32768 + assert retrieved.vision is False + +def test_fallback_to_vendor_default(): + caps = VendorCapabilities( + vendor='llama', + model='*', + context_window=131072, + cost_tracking=False + ) + register(caps) + retrieved = get_capabilities('llama', 'llama-3.3-70b-specdec') + assert retrieved.context_window == 131072 + assert retrieved.cost_tracking is False + +def test_unknown_vendor_raises(): + with pytest.raises(KeyError, match='No capabilities registered'): + get_capabilities('nonexistent_vendor', 'anymodel')