37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
import json
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from sssf_opencode.config import FactoryConfigError, load_factory_config
|
|
|
|
|
|
REPOSITORY = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class ModelRoutingTests(unittest.TestCase):
|
|
def test_default_routes_cover_the_requested_providers_without_credentials(self):
|
|
config = load_factory_config(REPOSITORY / "factory.json")
|
|
|
|
self.assertEqual(config.model_for("planner"), "zai-coding-plan/glm-5.2")
|
|
self.assertEqual(config.model_for("builder"), "openai/gpt-5.3-codex")
|
|
self.assertEqual(config.model_for("reviewer"), "minimax/MiniMax-M3")
|
|
self.assertEqual(
|
|
config.fallbacks_for("builder"),
|
|
("deepseek/deepseek-v4-pro", "zai-coding-plan/glm-5.2"),
|
|
)
|
|
self.assertFalse(config.models["deepseek-v4-pro"].enabled)
|
|
self.assertNotIn("api_key", (REPOSITORY / "factory.json").read_text().lower())
|
|
def test_rejects_credentials_in_factory_policy(self):
|
|
document = json.loads((REPOSITORY / "factory.json").read_text())
|
|
document["models"]["openai-codex"]["apiKey"] = "never-store-this"
|
|
with tempfile.TemporaryDirectory() as temp:
|
|
path = Path(temp) / "factory.json"
|
|
path.write_text(json.dumps(document))
|
|
with self.assertRaisesRegex(FactoryConfigError, "credential"):
|
|
load_factory_config(path)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|