Debian Codegraph @

tests/api_resources/beta/organization/test_compliance_settings.py

raw
1 from __future__ import annotations
2
3 import os
4 from typing import Any, cast
5
6 import pytest
7
8 from anthropic import Anthropic, AsyncAnthropic
9 from tests.utils import assert_matches_type
10 from anthropic.types.beta.organization import (
11 BetaComplianceSettings,
12 )
13
14 base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
15
16
17 class TestComplianceSettings:
18 parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
19
20 @parametrize
21 def test_method_retrieve(self, client: Anthropic) -> None:
22 compliance_setting = client.beta.organization.compliance_settings.retrieve()
23 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
24
25 @parametrize
26 def test_raw_response_retrieve(self, client: Anthropic) -> None:
27 response = client.beta.organization.compliance_settings.with_raw_response.retrieve()
28
29 assert response.is_closed is True
30 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
31 compliance_setting = response.parse()
32 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
33
34 @parametrize
35 def test_streaming_response_retrieve(self, client: Anthropic) -> None:
36 with client.beta.organization.compliance_settings.with_streaming_response.retrieve() as response:
37 assert not response.is_closed
38 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
39
40 compliance_setting = response.parse()
41 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
42
43 assert cast(Any, response.is_closed) is True
44
45 @parametrize
46 def test_method_update(self, client: Anthropic) -> None:
47 compliance_setting = client.beta.organization.compliance_settings.update(
48 state={"type": "enabled"},
49 )
50 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
51
52 @parametrize
53 def test_raw_response_update(self, client: Anthropic) -> None:
54 response = client.beta.organization.compliance_settings.with_raw_response.update(
55 state={"type": "enabled"},
56 )
57
58 assert response.is_closed is True
59 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
60 compliance_setting = response.parse()
61 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
62
63 @parametrize
64 def test_streaming_response_update(self, client: Anthropic) -> None:
65 with client.beta.organization.compliance_settings.with_streaming_response.update(
66 state={"type": "enabled"},
67 ) as response:
68 assert not response.is_closed
69 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
70
71 compliance_setting = response.parse()
72 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
73
74 assert cast(Any, response.is_closed) is True
75
76
77 class TestAsyncComplianceSettings:
78 parametrize = pytest.mark.parametrize(
79 "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
80 )
81
82 @parametrize
83 async def test_method_retrieve(self, async_client: AsyncAnthropic) -> None:
84 compliance_setting = await async_client.beta.organization.compliance_settings.retrieve()
85 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
86
87 @parametrize
88 async def test_raw_response_retrieve(self, async_client: AsyncAnthropic) -> None:
89 response = await async_client.beta.organization.compliance_settings.with_raw_response.retrieve()
90
91 assert response.is_closed is True
92 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
93 compliance_setting = await response.parse()
94 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
95
96 @parametrize
97 async def test_streaming_response_retrieve(self, async_client: AsyncAnthropic) -> None:
98 async with async_client.beta.organization.compliance_settings.with_streaming_response.retrieve() as response:
99 assert not response.is_closed
100 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
101
102 compliance_setting = await response.parse()
103 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
104
105 assert cast(Any, response.is_closed) is True
106
107 @parametrize
108 async def test_method_update(self, async_client: AsyncAnthropic) -> None:
109 compliance_setting = await async_client.beta.organization.compliance_settings.update(
110 state={"type": "enabled"},
111 )
112 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
113
114 @parametrize
115 async def test_raw_response_update(self, async_client: AsyncAnthropic) -> None:
116 response = await async_client.beta.organization.compliance_settings.with_raw_response.update(
117 state={"type": "enabled"},
118 )
119
120 assert response.is_closed is True
121 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
122 compliance_setting = await response.parse()
123 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
124
125 @parametrize
126 async def test_streaming_response_update(self, async_client: AsyncAnthropic) -> None:
127 async with async_client.beta.organization.compliance_settings.with_streaming_response.update(
128 state={"type": "enabled"},
129 ) as response:
130 assert not response.is_closed
131 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
132
133 compliance_setting = await response.parse()
134 assert_matches_type(BetaComplianceSettings, compliance_setting, path=["response"])
135
136 assert cast(Any, response.is_closed) is True