MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / test_copy_default_query

Method test_copy_default_query

tests/test_client.py:211–247  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

209 client.close()
210
211 def test_copy_default_query(self) -> None:
212 client = Anthropic(
213 base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"foo": "bar"}
214 )
215 assert _get_params(client)["foo"] == "bar"
216
217 # does not override the already given value when not specified
218 copied = client.copy()
219 assert _get_params(copied)["foo"] == "bar"
220
221 # merges already given params
222 copied = client.copy(default_query={"bar": "stainless"})
223 params = _get_params(copied)
224 assert params["foo"] == "bar"
225 assert params["bar"] == "stainless"
226
227 # uses new values for any already given headers
228 copied = client.copy(default_query={"foo": "stainless"})
229 assert _get_params(copied)["foo"] == "stainless"
230
231 # set_default_query
232
233 # completely overrides already set values
234 copied = client.copy(set_default_query={})
235 assert _get_params(copied) == {}
236
237 copied = client.copy(set_default_query={"bar": "Robert"})
238 assert _get_params(copied)["bar"] == "Robert"
239
240 with pytest.raises(
241 ValueError,
242 # TODO: update
243 match="`default_query` and `set_default_query` arguments are mutually exclusive",
244 ):
245 client.copy(set_default_query={}, default_query={"foo": "Bar"})
246
247 client.close()
248
249 def test_copy_signature(self, client: Anthropic) -> None:
250 # ensure the same parameters that can be passed to the client are defined in the `.copy()` method

Callers

nothing calls this directly

Calls 4

copyMethod · 0.95
closeMethod · 0.95
AnthropicClass · 0.90
_get_paramsFunction · 0.85

Tested by

no test coverage detected