refactor(providers): register shared setup templates

This commit is contained in:
Xubin Ren committed 2026-11-14 20:44:28 +08:00
1 parent 5eabed859c
commit ebb8419ddf
9 files changed
+193 -124

No files matched your search

+1 -1
View File
@@ -902,7 +902,7 @@ class TestMainMenuInteraction:
from nanobot.providers.registry import PROVIDERS
choices = onboard_wizard._get_quick_start_provider_choices()
selected_provider_names = set(choices.values())
selected_provider_names = {choice for choice in choices.values() if isinstance(choice, str)}
expected_provider_names = set()
seen_display_names: set[str] = set()
for spec in PROVIDERS:
+9 -5
View File
@@ -2901,13 +2901,17 @@ def test_setup_template_keeps_existing_provider_with_matching_name(tmp_path, mon
before = load_config(config_path)
monkeypatch.setattr("nanobot.config.loader._current_config_path", config_path)
settings = settings_payload()
template = next(item for item in settings["provider_setup_templates"] if item["id"] == "shengsuanyun")
assert template["label"] == "ShengSuanYun Router"
assert "胜算云" in template["search_aliases"].split()
assert template["suggested_name"] == "ShengSuanYun Router 2"
assert any(provider["name"] == legacy_key for provider in settings["providers"])
payload = create_provider_settings({
"name": ["ShengSuanYun Router 2"],
"apiBase": ["https://router.shengsuanyun.com/api/v1"],
"name": [template["suggested_name"]],
"apiBase": [template["api_base"]],
"apiKey": ["new-key"],
"api": [json.dumps({
"supportedApis": ["chat_completions", "responses"], "preferredApi": "chat_completions",
})],
"api": [json.dumps(template["api"])],
})
key = payload["created_provider"]
saved = load_config(config_path)