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
  dd332f9f_baa1_66e7_daf2_701c347cd3bf["test_batches.py"]
  bb0af148_44a9_df40_49c4_0fa6ceb5a403["os"]
  dd332f9f_baa1_66e7_daf2_701c347cd3bf --> bb0af148_44a9_df40_49c4_0fa6ceb5a403
  28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5["json"]
  dd332f9f_baa1_66e7_daf2_701c347cd3bf --> 28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  dd332f9f_baa1_66e7_daf2_701c347cd3bf --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  9c26e8a9_1ad2_1174_876a_1fc500ce0eaf["httpx"]
  dd332f9f_baa1_66e7_daf2_701c347cd3bf --> 9c26e8a9_1ad2_1174_876a_1fc500ce0eaf
  cde8421b_93c7_41e4_d69d_2a3f1bade2f2["pytest"]
  dd332f9f_baa1_66e7_daf2_701c347cd3bf --> cde8421b_93c7_41e4_d69d_2a3f1bade2f2
  f6010db4_1656_22a8_b4ae_e0060d80d8c6["respx"]
  dd332f9f_baa1_66e7_daf2_701c347cd3bf --> f6010db4_1656_22a8_b4ae_e0060d80d8c6
  d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"]
  dd332f9f_baa1_66e7_daf2_701c347cd3bf --> d10c5377_2939_0f0b_cc44_8759393f2853
  cf46c35e_ae7e_a652_f32b_5dd703f4d658["utils.py"]
  dd332f9f_baa1_66e7_daf2_701c347cd3bf --> cf46c35e_ae7e_a652_f32b_5dd703f4d658
  08e9c9e7_d7f9_615f_5837_b3de69122e37["assert_matches_type"]
  dd332f9f_baa1_66e7_daf2_701c347cd3bf --> 08e9c9e7_d7f9_615f_5837_b3de69122e37
  7bee6b18_3397_1147_6683_6b09ec705805["anthropic.pagination"]
  dd332f9f_baa1_66e7_daf2_701c347cd3bf --> 7bee6b18_3397_1147_6683_6b09ec705805
  ad531589_8ff6_312e_5946_4b65ce479a1e["anthropic.types.messages"]
  dd332f9f_baa1_66e7_daf2_701c347cd3bf --> ad531589_8ff6_312e_5946_4b65ce479a1e
  style dd332f9f_baa1_66e7_daf2_701c347cd3bf 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.messages import (
    MessageBatch,
    DeletedMessageBatch,
)

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"])

    @parametrize
    def test_method_create(self, client: Anthropic) -> None:
        batch = client.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(MessageBatch, batch, path=["response"])

    @parametrize
    def test_raw_response_create(self, client: Anthropic) -> None:
        response = client.messages.batches.with_raw_response.create(
            requests=[
                {
                    "custom_id": "my-custom-id-1",
                    "params": {
                        "max_tokens": 1024,
                        "messages": [
                            {
                                "content": "Hello, world",
                                "role": "user",
                            }
                        ],
// ... (473 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.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/messages/test_batches.py (domain: AnthropicClient, subdomain: Authentication, directory: tests/api_resources/messages).

Analyze Your Own Codebase

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

Try Supermodel Free