refactor: move all server config to startup env vars; drop plugin settings
This commit is contained in:
@@ -118,7 +118,9 @@ async def test_send_message_sync_omits_model_when_provider_or_model_missing(
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_message_sync_includes_system_when_provided() -> None:
|
||||
"""system param is forwarded into the request body when not None."""
|
||||
config = OpenCodeConfig(url="http://x:1", user="u", password="")
|
||||
config = OpenCodeConfig(
|
||||
url="http://x:1", user="u", password="", request_timeout_seconds=120
|
||||
)
|
||||
mock = MockHTTPClient()
|
||||
mock.responses.append((200, {"info": {}, "parts": []}))
|
||||
client = OpenCodeClient(config, http_client=mock)
|
||||
|
||||
@@ -17,21 +17,23 @@ def test_env_url_overrides_default(monkeypatch) -> None:
|
||||
assert config.url == "http://x:1"
|
||||
|
||||
|
||||
def test_jupyter_settings_override_env(monkeypatch) -> None:
|
||||
def test_jupyter_settings_are_ignored(monkeypatch) -> None:
|
||||
monkeypatch.setenv("OPENCODE_BRIDGE_URL", "http://x:1")
|
||||
settings = {"opencode_bridge": {"opencodeServerUrl": "http://y:2"}}
|
||||
config = resolve_config(settings)
|
||||
assert config.url == "http://y:2"
|
||||
assert config.url == "http://x:1"
|
||||
|
||||
|
||||
def test_all_env_vars(monkeypatch) -> None:
|
||||
monkeypatch.setenv("OPENCODE_BRIDGE_URL", "http://x:1")
|
||||
monkeypatch.setenv("OPENCODE_BRIDGE_USER", "u")
|
||||
monkeypatch.setenv("OPENCODE_BRIDGE_PASSWORD", "p")
|
||||
monkeypatch.setenv("OPENCODE_BRIDGE_TIMEOUT", "300")
|
||||
config = resolve_config({})
|
||||
assert config.url == "http://x:1"
|
||||
assert config.user == "u"
|
||||
assert config.password == "p"
|
||||
assert config.request_timeout_seconds == 300
|
||||
|
||||
|
||||
def test_auth_none_when_password_empty() -> None:
|
||||
@@ -44,11 +46,12 @@ def test_auth_when_password_set() -> None:
|
||||
url="http://127.0.0.1:4096",
|
||||
user="opencode",
|
||||
password="secret",
|
||||
request_timeout_seconds=120,
|
||||
)
|
||||
assert config.auth == ("opencode", "secret")
|
||||
|
||||
|
||||
def test_request_timeout_from_settings() -> None:
|
||||
settings = {"opencode_bridge": {"requestTimeoutSeconds": 300}}
|
||||
config = resolve_config(settings)
|
||||
def test_request_timeout_from_env(monkeypatch) -> None:
|
||||
monkeypatch.setenv("OPENCODE_BRIDGE_TIMEOUT", "300")
|
||||
config = resolve_config({})
|
||||
assert config.request_timeout_seconds == 300
|
||||
|
||||
Reference in New Issue
Block a user