0a9e277564
The 7 v1 fields (vision, tool_calling, caching, streaming, model_discovery, context_window, cost_tracking) plus 2 cost fields and notes are now extended by 12 v2 fields: local, reasoning, structured_output, code_execution, web_search, x_search, file_search, mcp_support, audio, video, grounding, computer_use All default to False. Registry entries continue to work unchanged (backward compatible). t4_1 of Phase 4. Tests: - 12 parameterized 'default is False' tests - 12 parameterized 'round-trip to True' tests - 3 'local flag' tests: per-model, wildcard fallback, vendor isolation - 3 pre-existing registry tests still pass - 96/96 vendor+tool+provider+import-isolation tests pass (no regressions; +27 new tests this commit)
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
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-future-unregistered')
|
|
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')
|
|
|
|
V2_FIELDS: list[str] = [
|
|
'local', 'reasoning', 'structured_output', 'code_execution',
|
|
'web_search', 'x_search', 'file_search', 'mcp_support',
|
|
'audio', 'video', 'grounding', 'computer_use',
|
|
]
|
|
|
|
@pytest.mark.parametrize('field_name', V2_FIELDS)
|
|
def test_v2_field_default_is_false(field_name: str) -> None:
|
|
caps = VendorCapabilities(vendor='test', model='m')
|
|
assert getattr(caps, field_name) is False, f'{field_name} should default to False'
|
|
|
|
@pytest.mark.parametrize('field_name', V2_FIELDS)
|
|
def test_v2_field_round_trip(field_name: str) -> None:
|
|
caps = VendorCapabilities(vendor='test', model='m', **{field_name: True})
|
|
assert getattr(caps, field_name) is True, f'{field_name} should round-trip to True'
|
|
|
|
def test_v2_local_flag_works_for_local_vendor() -> None:
|
|
register(VendorCapabilities(vendor='llama', model='llama-local-test-3.1', local=True))
|
|
caps = get_capabilities('llama', 'llama-local-test-3.1')
|
|
assert caps.local is True
|
|
|
|
def test_v2_local_flag_falls_back_to_wildcard() -> None:
|
|
register(VendorCapabilities(vendor='llama', model='*', local=True))
|
|
caps = get_capabilities('llama', 'some-unregistered-model-3.1-future')
|
|
assert caps.local is True
|
|
|
|
def test_v2_local_flag_does_not_affect_other_vendors() -> None:
|
|
register(VendorCapabilities(vendor='llama', model='*', local=True))
|
|
register(VendorCapabilities(vendor='qwen', model='*'))
|
|
caps = get_capabilities('qwen', 'qwen-turbo')
|
|
assert caps.local is False
|