Allow remote detect in production until local Ollama is connected.
Keep KANSHO_ENV=production and require an explicit operator flag instead of treating Prod as Development. Promote to Prod only via merge commit on main. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
dd7858347c
commit
af6fe55577
23 files changed
+236
-27
No files matched your search
@@ -17,6 +17,7 @@ Path(tempfile.gettempdir()).mkdir(parents=True, exist_ok=True)
|
||||
from model_catalog import (
|
||||
ModelWindow,
|
||||
catalog_ttl,
|
||||
list_provider_models,
|
||||
reset_catalog,
|
||||
resolve_generate_metadata,
|
||||
)
|
||||
@@ -181,12 +182,41 @@ def test_env_fallback_and_fail_closed() -> None:
|
||||
_restore_env(previous)
|
||||
|
||||
|
||||
def test_list_provider_models() -> None:
|
||||
reset_catalog()
|
||||
payload = {
|
||||
"data": [
|
||||
{"id": "openai/gpt-4.1-nano", "name": "GPT 4.1 Nano"},
|
||||
{"id": "openai/gpt-5.4", "context_length": 128000},
|
||||
{"id": "openai/gpt-4.1-nano"},
|
||||
]
|
||||
}
|
||||
with patch("model_catalog.httpx.get", lambda *args, **kwargs: FakeResponse(payload)):
|
||||
items = list_provider_models(_openrouter_config())
|
||||
expect([item["id"] for item in items] == ["openai/gpt-4.1-nano", "openai/gpt-5.4"], "picker lists unique ids")
|
||||
with patch("model_catalog.httpx.get", lambda *args, **kwargs: FakeResponse({"nope": True})):
|
||||
expect(list_provider_models(_openrouter_config()) == [], "picker soft-fails on bad catalog")
|
||||
fake = ProviderConfig(
|
||||
role="generate",
|
||||
name="fake",
|
||||
mode="fake",
|
||||
url="",
|
||||
model="fake",
|
||||
key="",
|
||||
local=True,
|
||||
zdr=True,
|
||||
no_train=True,
|
||||
)
|
||||
expect(list_provider_models(fake) == [], "fake provider has no catalog")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
test_reads_context_and_completion()
|
||||
test_model_not_in_catalog()
|
||||
test_incomplete_metadata()
|
||||
test_cache_hit_and_ttl_expiry()
|
||||
test_env_fallback_and_fail_closed()
|
||||
test_list_provider_models()
|
||||
print("model catalog tests passed.")
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user