Home / Class/ TestModels Class — anthropic-sdk-python Architecture

TestModels Class — anthropic-sdk-python Architecture

Architecture documentation for the TestModels class in test_models.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  9420f0ca_362d_2d1c_e552_899dff385bd0["TestModels"]
  2608af38_7f25_6a41_86ce_050d21936c7a["ModelInfo"]
  9420f0ca_362d_2d1c_e552_899dff385bd0 -->|extends| 2608af38_7f25_6a41_86ce_050d21936c7a
  6ce0fdb0_f6fa_7237_400b_a01fc41eb776["test_models.py"]
  9420f0ca_362d_2d1c_e552_899dff385bd0 -->|defined in| 6ce0fdb0_f6fa_7237_400b_a01fc41eb776
  2dc131df_15f6_eac7_d64d_173efaafb425["test_method_retrieve()"]
  9420f0ca_362d_2d1c_e552_899dff385bd0 -->|method| 2dc131df_15f6_eac7_d64d_173efaafb425
  78900ac5_0725_fa1e_e7be_383ed1b7ac97["test_method_retrieve_with_all_params()"]
  9420f0ca_362d_2d1c_e552_899dff385bd0 -->|method| 78900ac5_0725_fa1e_e7be_383ed1b7ac97
  a84ae48f_24ac_93a9_b681_1991a387bba9["test_raw_response_retrieve()"]
  9420f0ca_362d_2d1c_e552_899dff385bd0 -->|method| a84ae48f_24ac_93a9_b681_1991a387bba9
  11266d2c_6cf7_328c_908e_00305fccc018["test_streaming_response_retrieve()"]
  9420f0ca_362d_2d1c_e552_899dff385bd0 -->|method| 11266d2c_6cf7_328c_908e_00305fccc018
  165ae4b1_cbef_1258_54d5_0ff93e779606["test_path_params_retrieve()"]
  9420f0ca_362d_2d1c_e552_899dff385bd0 -->|method| 165ae4b1_cbef_1258_54d5_0ff93e779606
  23bb3092_51f0_24fa_c4df_198f16e64f86["test_method_list()"]
  9420f0ca_362d_2d1c_e552_899dff385bd0 -->|method| 23bb3092_51f0_24fa_c4df_198f16e64f86
  4aec2633_c42e_e13e_81f0_7de3a55e74d6["test_method_list_with_all_params()"]
  9420f0ca_362d_2d1c_e552_899dff385bd0 -->|method| 4aec2633_c42e_e13e_81f0_7de3a55e74d6
  097f1c15_d1e1_3e05_e932_f44df3d56782["test_raw_response_list()"]
  9420f0ca_362d_2d1c_e552_899dff385bd0 -->|method| 097f1c15_d1e1_3e05_e932_f44df3d56782
  d82821b9_0ab3_3bdb_2536_14c3b383b4f4["test_streaming_response_list()"]
  9420f0ca_362d_2d1c_e552_899dff385bd0 -->|method| d82821b9_0ab3_3bdb_2536_14c3b383b4f4

Relationship Graph

Source Code

tests/api_resources/test_models.py lines 18–100

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

    @parametrize
    def test_method_retrieve(self, client: Anthropic) -> None:
        model = client.models.retrieve(
            model_id="model_id",
        )
        assert_matches_type(ModelInfo, model, path=["response"])

    @parametrize
    def test_method_retrieve_with_all_params(self, client: Anthropic) -> None:
        model = client.models.retrieve(
            model_id="model_id",
            betas=["string"],
        )
        assert_matches_type(ModelInfo, model, path=["response"])

    @parametrize
    def test_raw_response_retrieve(self, client: Anthropic) -> None:
        response = client.models.with_raw_response.retrieve(
            model_id="model_id",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        model = response.parse()
        assert_matches_type(ModelInfo, model, path=["response"])

    @parametrize
    def test_streaming_response_retrieve(self, client: Anthropic) -> None:
        with client.models.with_streaming_response.retrieve(
            model_id="model_id",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            model = response.parse()
            assert_matches_type(ModelInfo, model, path=["response"])

        assert cast(Any, response.is_closed) is True

    @parametrize
    def test_path_params_retrieve(self, client: Anthropic) -> None:
        with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_id` but received ''"):
            client.models.with_raw_response.retrieve(
                model_id="",
            )

    @parametrize
    def test_method_list(self, client: Anthropic) -> None:
        model = client.models.list()
        assert_matches_type(SyncPage[ModelInfo], model, path=["response"])

    @parametrize
    def test_method_list_with_all_params(self, client: Anthropic) -> None:
        model = client.models.list(
            after_id="after_id",
            before_id="before_id",
            limit=1,
            betas=["string"],
        )
        assert_matches_type(SyncPage[ModelInfo], model, path=["response"])

    @parametrize
    def test_raw_response_list(self, client: Anthropic) -> None:
        response = client.models.with_raw_response.list()

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        model = response.parse()
        assert_matches_type(SyncPage[ModelInfo], model, path=["response"])

    @parametrize
    def test_streaming_response_list(self, client: Anthropic) -> None:
        with client.models.with_streaming_response.list() as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            model = response.parse()
            assert_matches_type(SyncPage[ModelInfo], model, path=["response"])

Extends

Frequently Asked Questions

What is the TestModels class?
TestModels is a class in the anthropic-sdk-python codebase, defined in tests/api_resources/test_models.py.
Where is TestModels defined?
TestModels is defined in tests/api_resources/test_models.py at line 18.
What does TestModels extend?
TestModels extends ModelInfo.

Analyze Your Own Codebase

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

Try Supermodel Free