This commit is contained in:
@@ -10,10 +10,10 @@ from cloud_api.app import create_app
|
||||
|
||||
class _FakePlannerClient:
|
||||
def __init__(self) -> None:
|
||||
self.calls = 0
|
||||
self.calls: list[dict[str, object]] = []
|
||||
|
||||
def decide(self, **_kwargs) -> ToolCallDecision:
|
||||
self.calls += 1
|
||||
def decide(self, **kwargs) -> ToolCallDecision:
|
||||
self.calls.append(kwargs)
|
||||
return ToolCallDecision(tool_name="tap", arguments={"x": 1, "y": 2})
|
||||
|
||||
|
||||
@@ -38,7 +38,12 @@ def _login_admin(client: TestClient) -> dict[str, str]:
|
||||
|
||||
|
||||
def _create_profile(
|
||||
client: TestClient, headers: dict[str, str], *, name: str, model: str
|
||||
client: TestClient,
|
||||
headers: dict[str, str],
|
||||
*,
|
||||
name: str,
|
||||
model: str,
|
||||
timeout_seconds: float,
|
||||
) -> dict:
|
||||
response = client.post(
|
||||
"/v1/planner/providers",
|
||||
@@ -48,7 +53,7 @@ def _create_profile(
|
||||
"provider_type": "openai-compatible",
|
||||
"model": model,
|
||||
"base_url": "https://compat.example/v1",
|
||||
"timeout_seconds": 30,
|
||||
"timeout_seconds": timeout_seconds,
|
||||
"api_key": f"key-for-{name}",
|
||||
},
|
||||
)
|
||||
@@ -95,7 +100,11 @@ def test_planner_uses_the_newly_activated_database_profile(monkeypatch) -> None:
|
||||
with TestClient(app) as client:
|
||||
admin_headers = _login_admin(client)
|
||||
first = _create_profile(
|
||||
client, admin_headers, name="First", model="first-model"
|
||||
client,
|
||||
admin_headers,
|
||||
name="First",
|
||||
model="first-model",
|
||||
timeout_seconds=41,
|
||||
)
|
||||
assert (
|
||||
client.post(
|
||||
@@ -115,9 +124,14 @@ def test_planner_uses_the_newly_activated_database_profile(monkeypatch) -> None:
|
||||
assert first_decision.status_code == 200, first_decision.text
|
||||
assert resolved_profiles[-1].profile.model == "first-model"
|
||||
assert resolved_profiles[-1].api_key == "key-for-First"
|
||||
assert fake.calls[-1]["timeout"] == 41
|
||||
|
||||
second = _create_profile(
|
||||
client, admin_headers, name="Second", model="second-model"
|
||||
client,
|
||||
admin_headers,
|
||||
name="Second",
|
||||
model="second-model",
|
||||
timeout_seconds=57,
|
||||
)
|
||||
settings = client.get("/v1/planner/providers").json()["settings"]
|
||||
activated = client.post(
|
||||
@@ -134,7 +148,8 @@ def test_planner_uses_the_newly_activated_database_profile(monkeypatch) -> None:
|
||||
)
|
||||
assert second_decision.status_code == 200, second_decision.text
|
||||
assert resolved_profiles[-1].profile.model == "second-model"
|
||||
assert fake.calls == 2
|
||||
assert fake.calls[-1]["timeout"] == 57
|
||||
assert len(fake.calls) == 2
|
||||
|
||||
|
||||
def test_planner_fails_closed_without_an_active_database_profile(monkeypatch) -> None:
|
||||
|
||||
Reference in New Issue
Block a user