test_vertex.py — anthropic-sdk-python Source File
Architecture documentation for test_vertex.py, a python file in the anthropic-sdk-python codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR db230024_6f86_b90f_ba9d_ea89f56ffac7["test_vertex.py"] bb0af148_44a9_df40_49c4_0fa6ceb5a403["os"] db230024_6f86_b90f_ba9d_ea89f56ffac7 --> bb0af148_44a9_df40_49c4_0fa6ceb5a403 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"] db230024_6f86_b90f_ba9d_ea89f56ffac7 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875 37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"] db230024_6f86_b90f_ba9d_ea89f56ffac7 --> 37c05070_ca59_d596_7250_de9d1939227f 9c26e8a9_1ad2_1174_876a_1fc500ce0eaf["httpx"] db230024_6f86_b90f_ba9d_ea89f56ffac7 --> 9c26e8a9_1ad2_1174_876a_1fc500ce0eaf cde8421b_93c7_41e4_d69d_2a3f1bade2f2["pytest"] db230024_6f86_b90f_ba9d_ea89f56ffac7 --> cde8421b_93c7_41e4_d69d_2a3f1bade2f2 f6010db4_1656_22a8_b4ae_e0060d80d8c6["respx"] db230024_6f86_b90f_ba9d_ea89f56ffac7 --> f6010db4_1656_22a8_b4ae_e0060d80d8c6 d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"] db230024_6f86_b90f_ba9d_ea89f56ffac7 --> d10c5377_2939_0f0b_cc44_8759393f2853 style db230024_6f86_b90f_ba9d_ea89f56ffac7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import os
from typing import cast
from typing_extensions import Protocol
import httpx
import pytest
from respx import MockRouter
from anthropic import AnthropicVertex, AsyncAnthropicVertex
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
class MockRequestCall(Protocol):
request: httpx.Request
class TestAnthropicVertex:
client = AnthropicVertex(region="region", project_id="project", access_token="my-access-token")
@pytest.mark.respx()
def test_messages_retries(self, respx_mock: MockRouter) -> None:
request_url = "https://region-aiplatform.googleapis.com/v1/projects/project/locations/region/publishers/anthropic/models/claude-3-sonnet@20240229:rawPredict"
respx_mock.post(request_url).mock(
side_effect=[
httpx.Response(500, json={"error": "server error"}, headers={"retry-after-ms": "10"}),
httpx.Response(200, json={"foo": "bar"}),
]
)
self.client.messages.create(
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Say hello there!",
}
],
model="claude-3-sonnet@20240229",
)
calls = cast("list[MockRequestCall]", respx_mock.calls)
assert len(calls) == 2
assert calls[0].request.url == request_url
assert calls[1].request.url == request_url
def test_copy(self) -> None:
copied = self.client.copy()
assert id(copied) != id(self.client)
copied = self.client.copy(region="another-region", project_id="another-project")
assert copied.region == "another-region"
assert self.client.region == "region"
assert copied.project_id == "another-project"
assert self.client.project_id == "project"
// ... (219 more lines)
Domain
Subdomains
Dependencies
- anthropic
- httpx
- os
- pytest
- respx
- typing
- typing_extensions
Source
Frequently Asked Questions
What does test_vertex.py do?
test_vertex.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, Authentication subdomain.
What does test_vertex.py depend on?
test_vertex.py imports 7 module(s): anthropic, httpx, os, pytest, respx, typing, typing_extensions.
Where is test_vertex.py in the architecture?
test_vertex.py is located at tests/lib/test_vertex.py (domain: AnthropicClient, subdomain: Authentication, directory: tests/lib).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free