feat(fase2): wire local + Foundry profiles + model-map + env template
This commit is contained in:
parent
f981c51e0b
commit
15e41dd1fa
3 changed files with 88 additions and 42 deletions
|
|
@ -1,6 +1,7 @@
|
|||
"""Tests for the backend profile skeleton (D2)."""
|
||||
"""Tests for the backend profiles (D2) — now wired (Fase 2), no longer skeletons."""
|
||||
|
||||
import pytest
|
||||
from agent_framework import BaseChatClient
|
||||
|
||||
from portfolio_optimiser.backends import (
|
||||
AzureFoundryBackend,
|
||||
|
|
@ -8,6 +9,7 @@ from portfolio_optimiser.backends import (
|
|||
LocalBackend,
|
||||
Profile,
|
||||
get_backend,
|
||||
resolve_model,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -32,8 +34,21 @@ def test_unknown_profile_fails_fast() -> None:
|
|||
get_backend("on-prem")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("profile", ["azure", "local"])
|
||||
def test_create_chat_client_is_skeleton(profile: str) -> None:
|
||||
# Fase 0: the seam is defined but not wired — must fail loudly, not silently.
|
||||
with pytest.raises(NotImplementedError):
|
||||
get_backend(profile).create_chat_client(model="dummy-model")
|
||||
def test_local_backend_returns_client_no_network(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
# Construction is offline (no network); the default base_url is loopback.
|
||||
monkeypatch.delenv("PORTFOLIO_LOCAL_BASE_URL", raising=False)
|
||||
client = get_backend("local").create_chat_client(model="qwen3:4b")
|
||||
assert isinstance(client, BaseChatClient)
|
||||
|
||||
|
||||
def test_azure_backend_fails_fast_without_endpoint(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
# Fail-fast (no silent default endpoint) — the operator must supply the Foundry endpoint.
|
||||
monkeypatch.delenv("PORTFOLIO_FOUNDRY_PROJECT_ENDPOINT", raising=False)
|
||||
with pytest.raises(ValueError):
|
||||
get_backend("azure").create_chat_client(model="dummy-deployment")
|
||||
|
||||
|
||||
def test_model_map_resolves_role_to_model() -> None:
|
||||
assert resolve_model("local", "proposer") == "qwen3:4b"
|
||||
# Unknown role falls back to the profile default (still a non-empty id).
|
||||
assert resolve_model(Profile.LOCAL, "no-such-role")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue