TestAnthropicFoundry Class — anthropic-sdk-python Architecture
Architecture documentation for the TestAnthropicFoundry class in test_azure.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD c9055898_f4e8_516f_40b3_e818e75c1549["TestAnthropicFoundry"] 145ee5ba_422d_688e_ca30_dbf4a26bf47f["AnthropicError"] c9055898_f4e8_516f_40b3_e818e75c1549 -->|extends| 145ee5ba_422d_688e_ca30_dbf4a26bf47f 010e17e5_4eab_021f_d798_ecbf0066bdc8["test_azure.py"] c9055898_f4e8_516f_40b3_e818e75c1549 -->|defined in| 010e17e5_4eab_021f_d798_ecbf0066bdc8 7f40da3b_2231_c518_76e4_a7283df9ed87["test_basic_initialization_with_api_key()"] c9055898_f4e8_516f_40b3_e818e75c1549 -->|method| 7f40da3b_2231_c518_76e4_a7283df9ed87 bbc2f980_8d7f_71e7_8249_f74eb23bfcbd["test_initialization_with_base_url()"] c9055898_f4e8_516f_40b3_e818e75c1549 -->|method| bbc2f980_8d7f_71e7_8249_f74eb23bfcbd 3becd361_ef60_5a88_0e16_f1c574b2996b["test_initialization_with_azure_ad_token_provider()"] c9055898_f4e8_516f_40b3_e818e75c1549 -->|method| 3becd361_ef60_5a88_0e16_f1c574b2996b f0ec7e84_e12b_f4dc_2a7c_bb0e3930136b["test_initialization_from_environment_variables()"] c9055898_f4e8_516f_40b3_e818e75c1549 -->|method| f0ec7e84_e12b_f4dc_2a7c_bb0e3930136b 1af73c53_de56_3d0f_a546_52bdd227ab88["test_missing_credentials_error()"] c9055898_f4e8_516f_40b3_e818e75c1549 -->|method| 1af73c53_de56_3d0f_a546_52bdd227ab88 4613462d_36a5_80bd_07b9_ee95662e5c3e["test_missing_resource_error()"] c9055898_f4e8_516f_40b3_e818e75c1549 -->|method| 4613462d_36a5_80bd_07b9_ee95662e5c3e
Relationship Graph
Source Code
tests/lib/test_azure.py lines 9–66
class TestAnthropicFoundry:
def test_basic_initialization_with_api_key(self) -> None:
"""Test basic client initialization with API key."""
client = AnthropicFoundry(
api_key="test-key",
resource="example-resource",
)
assert client.api_key == "test-key"
assert str(client.base_url) == "https://example-resource.services.ai.azure.com/anthropic/"
def test_initialization_with_base_url(self) -> None:
"""Test client initialization with base_url instead of resource."""
client = AnthropicFoundry(
api_key="test-key",
base_url="https://example.services.ai.azure.com/anthropic/",
)
assert str(client.base_url) == "https://example.services.ai.azure.com/anthropic/"
def test_initialization_with_azure_ad_token_provider(self) -> None:
"""Test client initialization with Azure AD token provider."""
def token_provider() -> str:
return "test-token"
client = AnthropicFoundry(
azure_ad_token_provider=token_provider,
resource="example-resource",
)
assert client._azure_ad_token_provider is not None
assert client._get_azure_ad_token() == "test-token"
def test_initialization_from_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None:
"""Test client initialization falls back to environment variables."""
monkeypatch.setenv("ANTHROPIC_FOUNDRY_API_KEY", "env-key")
monkeypatch.setenv("ANTHROPIC_API_VERSION", "2023-06-01")
monkeypatch.setenv("ANTHROPIC_FOUNDRY_RESOURCE", "env-resource")
client = AnthropicFoundry()
assert client.api_key == "env-key"
assert "env-resource.services.ai.azure.com" in str(client.base_url)
def test_missing_credentials_error(self) -> None:
"""Test error raised when no credentials are provided."""
with pytest.raises(AnthropicError, match="Missing credentials"):
AnthropicFoundry(
resource="example-resource",
)
def test_missing_resource_error(self) -> None:
"""Test error raised when neither resource nor base_url is provided."""
with pytest.raises(ValueError, match="base_url.*resource"):
AnthropicFoundry(
api_key="test-key",
)
Defined In
Extends
Source
Frequently Asked Questions
What is the TestAnthropicFoundry class?
TestAnthropicFoundry is a class in the anthropic-sdk-python codebase, defined in tests/lib/test_azure.py.
Where is TestAnthropicFoundry defined?
TestAnthropicFoundry is defined in tests/lib/test_azure.py at line 9.
What does TestAnthropicFoundry extend?
TestAnthropicFoundry extends AnthropicError.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free