feat(zen): add live model sync
This commit is contained in:
61
tests/test_sync_zen_models.py
Normal file
61
tests/test_sync_zen_models.py
Normal file
@@ -0,0 +1,61 @@
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
SCRIPT_PATH = Path(__file__).resolve().parents[1] / "scripts" / "sync_zen_models.py"
|
||||
SPEC = importlib.util.spec_from_file_location("sync_zen_models", SCRIPT_PATH)
|
||||
assert SPEC is not None and SPEC.loader is not None
|
||||
MODULE = importlib.util.module_from_spec(SPEC)
|
||||
SPEC.loader.exec_module(MODULE)
|
||||
|
||||
|
||||
def test_convert_model_applies_family_defaults_for_gpt_5_4():
|
||||
converted = MODULE.convert_model({"id": "gpt-5.4"}, curated_models={})
|
||||
|
||||
assert converted is not None
|
||||
assert converted["model_name"] == "gpt-5.4"
|
||||
assert converted["context_window"] == 1050000
|
||||
assert converted["max_output_tokens"] == 128000
|
||||
assert converted["supports_extended_thinking"] is True
|
||||
assert converted["supports_images"] is True
|
||||
assert converted["use_openai_response_api"] is True
|
||||
|
||||
|
||||
def test_convert_model_prefers_curated_metadata_when_available():
|
||||
converted = MODULE.convert_model(
|
||||
{"id": "claude-opus-4-5"},
|
||||
curated_models={
|
||||
"claude-opus-4-5": {
|
||||
"context_window": 200000,
|
||||
"max_output_tokens": 64000,
|
||||
"supports_extended_thinking": False,
|
||||
"description": "Curated Opus 4.5",
|
||||
"intelligence_score": 18,
|
||||
"allow_code_generation": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
assert converted is not None
|
||||
assert converted["model_name"] == "claude-opus-4-5"
|
||||
assert converted["context_window"] == 200000
|
||||
assert converted["max_output_tokens"] == 64000
|
||||
assert converted["supports_extended_thinking"] is False
|
||||
assert converted["description"] == "Curated Opus 4.5"
|
||||
assert converted["allow_code_generation"] is True
|
||||
|
||||
|
||||
def test_build_output_document_sorts_model_ids():
|
||||
document = MODULE.build_output_document(
|
||||
{
|
||||
"data": [
|
||||
{"id": "gpt-5.4-pro"},
|
||||
{"id": "claude-opus-4-6"},
|
||||
]
|
||||
},
|
||||
"https://opencode.ai/zen/v1/models",
|
||||
curated_models={},
|
||||
)
|
||||
|
||||
model_names = [item["model_name"] for item in document["models"]]
|
||||
assert model_names == sorted(model_names)
|
||||
Reference in New Issue
Block a user