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

test_batches.py — anthropic-sdk-python Source File

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

File python AnthropicClient Authentication 11 imports 2 classes

Entity Profile

Dependency Diagram

graph LR
  8338a118_0daa_4bed_30d9_2d313e1f3766["test_batches.py"]
  bb0af148_44a9_df40_49c4_0fa6ceb5a403["os"]
  8338a118_0daa_4bed_30d9_2d313e1f3766 --> bb0af148_44a9_df40_49c4_0fa6ceb5a403
  28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5["json"]
  8338a118_0daa_4bed_30d9_2d313e1f3766 --> 28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  8338a118_0daa_4bed_30d9_2d313e1f3766 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  9c26e8a9_1ad2_1174_876a_1fc500ce0eaf["httpx"]
  8338a118_0daa_4bed_30d9_2d313e1f3766 --> 9c26e8a9_1ad2_1174_876a_1fc500ce0eaf
  cde8421b_93c7_41e4_d69d_2a3f1bade2f2["pytest"]
  8338a118_0daa_4bed_30d9_2d313e1f3766 --> cde8421b_93c7_41e4_d69d_2a3f1bade2f2
  f6010db4_1656_22a8_b4ae_e0060d80d8c6["respx"]
  8338a118_0daa_4bed_30d9_2d313e1f3766 --> f6010db4_1656_22a8_b4ae_e0060d80d8c6
  d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"]
  8338a118_0daa_4bed_30d9_2d313e1f3766 --> d10c5377_2939_0f0b_cc44_8759393f2853
  cf46c35e_ae7e_a652_f32b_5dd703f4d658["utils.py"]
  8338a118_0daa_4bed_30d9_2d313e1f3766 --> cf46c35e_ae7e_a652_f32b_5dd703f4d658
  08e9c9e7_d7f9_615f_5837_b3de69122e37["assert_matches_type"]
  8338a118_0daa_4bed_30d9_2d313e1f3766 --> 08e9c9e7_d7f9_615f_5837_b3de69122e37
  7bee6b18_3397_1147_6683_6b09ec705805["anthropic.pagination"]
  8338a118_0daa_4bed_30d9_2d313e1f3766 --> 7bee6b18_3397_1147_6683_6b09ec705805
  7a120c33_313a_ebfa_43ae_88a513b222b4["anthropic.types.beta.messages"]
  8338a118_0daa_4bed_30d9_2d313e1f3766 --> 7a120c33_313a_ebfa_43ae_88a513b222b4
  style 8338a118_0daa_4bed_30d9_2d313e1f3766 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

import os
import json
from typing import Any, cast

import httpx
import pytest
from respx import MockRouter

from anthropic import Anthropic, AsyncAnthropic
from tests.utils import assert_matches_type
from anthropic.pagination import SyncPage, AsyncPage
from anthropic.types.beta.messages import (
    BetaMessageBatch,
    BetaDeletedMessageBatch,
)

base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")


class TestBatches:
    parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])

    @pytest.mark.skip(reason="prism validates based on the non-beta endpoint")
    @parametrize
    def test_method_create(self, client: Anthropic) -> None:
        batch = client.beta.messages.batches.create(
            requests=[
                {
                    "custom_id": "my-custom-id-1",
                    "params": {
                        "max_tokens": 1024,
                        "messages": [
                            {
                                "content": "Hello, world",
                                "role": "user",
                            }
                        ],
                        "model": "claude-opus-4-6",
                    },
                }
            ],
        )
        assert_matches_type(BetaMessageBatch, batch, path=["response"])

    @pytest.mark.skip(reason="prism validates based on the non-beta endpoint")
    @parametrize
    def test_method_create_with_all_params(self, client: Anthropic) -> None:
        batch = client.beta.messages.batches.create(
            requests=[
                {
                    "custom_id": "my-custom-id-1",
                    "params": {
                        "max_tokens": 1024,
                        "messages": [
                            {
                                "content": "Hello, world",
// ... (825 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does test_batches.py do?
test_batches.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_batches.py depend on?
test_batches.py imports 11 module(s): anthropic, anthropic.pagination, anthropic.types.beta.messages, assert_matches_type, httpx, json, os, pytest, and 3 more.
Where is test_batches.py in the architecture?
test_batches.py is located at tests/api_resources/beta/messages/test_batches.py (domain: AnthropicClient, subdomain: Authentication, directory: tests/api_resources/beta/messages).

Analyze Your Own Codebase

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

Try Supermodel Free