Private
Public Access
0
0

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.
This commit is contained in:
2026-06-11 00:19:00 -04:00
parent cd2557bc4a
commit 6fb6f8653c
+40
View File
@@ -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')