refactor(config)!: retire the old OpenAI API selector (#6615)

Co-authored-by: chengyongru <chengyongru.ai@gmail.com>
This commit is contained in:
Xubin Renandchengyongru authored and GitHub committed 2026-11-11 17:07:18 +08:00
1 parent e3a1af2ed3
commit 5c1083df7f
14 files changed
+112 -141

No files matched your search

+3 -4
View File
@@ -998,7 +998,7 @@ def test_update_provider_settings_persists_provider_specific_advanced_options(
update_provider_settings(
{
"provider": ["openai"],
"apiType": ["responses"],
"api": [json.dumps({"supportedApis": ["responses"]})],
"use_proxy": ["true"],
"extraHeaders": [json.dumps({"X-Trace": "enabled"})],
"extraBody": [json.dumps({"service_tier": "priority"})],
@@ -2852,13 +2852,12 @@ def test_custom_connection_cannot_remove_api_used_by_legacy_or_inline_model(tmp_
assert config_path.read_bytes() == before
@pytest.mark.parametrize("field", ["apiType", "api_type"])
def test_legacy_openai_settings_can_return_to_auto(monkeypatch, tmp_path, field):
def test_openai_settings_can_return_to_auto(monkeypatch, tmp_path):
config_path = tmp_path / "config.json"
config = Config.model_validate({"providers": {"openai": {
"apiKey": "fixture", "api": {"supportedApis": ["responses"]},
}}})
save_config(config, config_path)
monkeypatch.setattr("nanobot.config.loader._current_config_path", config_path)
update_provider_settings({"provider": ["openai"], field: ["auto"]})
update_provider_settings({"provider": ["openai"], "api": ["null"]})
assert load_config(config_path).providers.openai.api is None
+19
View File
@@ -764,6 +764,25 @@ async def test_model_update_route_forwards_session_rename_dependency(monkeypatch
refresh_runtime_config.assert_called_once_with()
@pytest.mark.asyncio
async def test_older_client_does_not_partially_update_provider_settings(tmp_path) -> None:
config_path = tmp_path / "config.json"
before = '{"providers":{"openai":{"apiKey":"fixture","api":{"supportedApis":["responses"]}}}}'
config_path.write_text(before, encoding="utf-8")
refresh = MagicMock()
router = _router(config_path=config_path, refresh_runtime_config=refresh)
path = "/api/settings/provider/update"
request = _mutation_request(path, {"provider": "openai", "apiType": "auto", "apiBase": "https://example.test/v1"})
response = await router.dispatch(None, request, path)
assert response is not None
assert response.status_code == 400
assert "Update the client" in json.loads(response.body)["error"]
assert config_path.read_text(encoding="utf-8") == before
refresh.assert_not_called()
@pytest.mark.asyncio
async def test_settings_get_mutation_route_is_method_not_allowed() -> None:
path = "/api/settings/provider/update"