"""Tests for the backend profile skeleton (D2).""" import pytest from portfolio_optimiser.backends import ( AzureFoundryBackend, ChatBackend, LocalBackend, Profile, get_backend, ) def test_get_backend_by_string() -> None: assert isinstance(get_backend("azure"), AzureFoundryBackend) assert isinstance(get_backend("local"), LocalBackend) def test_get_backend_by_enum() -> None: assert get_backend(Profile.AZURE).profile is Profile.AZURE assert get_backend(Profile.LOCAL).profile is Profile.LOCAL def test_backends_satisfy_seam() -> None: # Structural conformance to the ChatBackend Protocol (the D2 seam). assert isinstance(get_backend("azure"), ChatBackend) assert isinstance(get_backend("local"), ChatBackend) def test_unknown_profile_fails_fast() -> None: with pytest.raises(ValueError): 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")