Files
agentic-mobile-control/apps/cloud-api/tests/test_cloud_planner_config.py
T
2026-07-14 00:31:47 +08:00

52 lines
1.7 KiB
Python

from __future__ import annotations
from datetime import UTC, datetime
from cloud.llm_providers import LlmProviderProfile, ResolvedLlmProviderProfile
from cloud.planner_config import build_cloud_planner_client
from runtime.tool_calling_client import (
AnthropicToolCallingClient,
OpenAIToolCallingClient,
)
def _resolved_profile(
provider_type: str, *, base_url: str | None = None
) -> ResolvedLlmProviderProfile:
now = datetime.now(UTC)
profile = LlmProviderProfile(
id="provider-1",
name="Managed provider",
name_normalized="managed provider",
provider_type=provider_type, # type: ignore[arg-type]
model="test-model",
base_url=base_url,
timeout_seconds=15,
api_key_ciphertext="ciphertext",
key_last_rotated_at=now,
enabled=True,
revision=1,
created_at=now,
updated_at=now,
)
return ResolvedLlmProviderProfile(profile=profile, api_key="managed-api-key")
def test_build_cloud_planner_client_uses_managed_anthropic_key() -> None:
client = build_cloud_planner_client(_resolved_profile("anthropic"))
assert isinstance(client, AnthropicToolCallingClient)
assert client.model == "test-model"
assert client._api_key == "managed-api-key"
def test_build_cloud_planner_client_uses_openai_compatible_base_url() -> None:
client = build_cloud_planner_client(
_resolved_profile("openai-compatible", base_url="https://compat.example/v1")
)
assert isinstance(client, OpenAIToolCallingClient)
assert client.model == "test-model"
assert client._api_key == "managed-api-key"
assert client._base_url == "https://compat.example/v1"