Home / File/ test_bedrock.py — anthropic-sdk-python Source File

test_bedrock.py — anthropic-sdk-python Source File

Architecture documentation for test_bedrock.py, a python file in the anthropic-sdk-python codebase. 8 imports, 0 dependents.

File python AnthropicClient SyncAPI 8 imports 8 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1["test_bedrock.py"]
  cc059f4f_d2bd_7056_9086_eaeec58cbdc0["re"]
  ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1 --> cc059f4f_d2bd_7056_9086_eaeec58cbdc0
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  58879ca5_9ef6_ec6b_6092_be2c9a1d3421["tempfile"]
  ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1 --> 58879ca5_9ef6_ec6b_6092_be2c9a1d3421
  37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"]
  ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1 --> 37c05070_ca59_d596_7250_de9d1939227f
  9c26e8a9_1ad2_1174_876a_1fc500ce0eaf["httpx"]
  ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1 --> 9c26e8a9_1ad2_1174_876a_1fc500ce0eaf
  cde8421b_93c7_41e4_d69d_2a3f1bade2f2["pytest"]
  ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1 --> cde8421b_93c7_41e4_d69d_2a3f1bade2f2
  f6010db4_1656_22a8_b4ae_e0060d80d8c6["respx"]
  ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1 --> f6010db4_1656_22a8_b4ae_e0060d80d8c6
  d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"]
  ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1 --> d10c5377_2939_0f0b_cc44_8759393f2853
  style ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import re
import typing as t
import tempfile
from typing import TypedDict, cast
from typing_extensions import Protocol

import httpx
import pytest
from respx import MockRouter

from anthropic import AnthropicBedrock, AsyncAnthropicBedrock

sync_client = AnthropicBedrock(
    aws_region="us-east-1",
    aws_access_key="example-access-key",
    aws_secret_key="example-secret-key",
)
async_client = AsyncAnthropicBedrock(
    aws_region="us-east-1",
    aws_access_key="example-access-key",
    aws_secret_key="example-secret-key",
)


class MockRequestCall(Protocol):
    request: httpx.Request


class AwsConfigProfile(TypedDict):
    # Available regions: https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-regions.html#available-regions
    name: t.Union[t.Literal["default"], str]
    region: str


def profile_to_ini(profile: AwsConfigProfile) -> str:
    """
    Convert an AWS config profile to an INI format string.
    """

    profile_name = profile["name"] if profile["name"] == "default" else f"profile {profile['name']}"
    return f"[{profile_name}]\nregion = {profile['region']}\n"


@pytest.fixture
def profiles() -> t.List[AwsConfigProfile]:
    return [
        {"name": "default", "region": "us-east-2"},
    ]


@pytest.fixture
def mock_aws_config(
    profiles: t.List[AwsConfigProfile],
    monkeypatch: t.Any,
) -> t.Iterable[None]:
    with tempfile.NamedTemporaryFile(mode="w+", delete=True) as temp_file:
        for profile in profiles:
            temp_file.write(profile_to_ini(profile))
        temp_file.flush()
        monkeypatch.setenv("AWS_CONFIG_FILE", str(temp_file.name))
// ... (138 more lines)

Subdomains

Dependencies

  • anthropic
  • httpx
  • pytest
  • re
  • respx
  • tempfile
  • typing
  • typing_extensions

Frequently Asked Questions

What does test_bedrock.py do?
test_bedrock.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What functions are defined in test_bedrock.py?
test_bedrock.py defines 8 function(s): mock_aws_config, profile_to_ini, profiles, test_application_inference_profile, test_messages_retries, test_messages_retries_async, test_region_infer_from_profile, test_region_infer_from_specified_profile.
What does test_bedrock.py depend on?
test_bedrock.py imports 8 module(s): anthropic, httpx, pytest, re, respx, tempfile, typing, typing_extensions.
Where is test_bedrock.py in the architecture?
test_bedrock.py is located at tests/lib/test_bedrock.py (domain: AnthropicClient, subdomain: SyncAPI, directory: tests/lib).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free