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

Method test_copy_default_query

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

Source from the content-addressed store, hash-verified

263 client.close()
264
265 def test_copy_default_query(self) -> None:
266 client = Anthropic(
267 base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"foo": "bar"}
268 )
269 assert _get_params(client)["foo"] == "bar"
270
271 # does not override the already given value when not specified
272 copied = client.copy()
273 assert _get_params(copied)["foo"] == "bar"
274
275 # merges already given params
276 copied = client.copy(default_query={"bar": "stainless"})
277 params = _get_params(copied)
278 assert params["foo"] == "bar"
279 assert params["bar"] == "stainless"
280
281 # uses new values for any already given headers
282 copied = client.copy(default_query={"foo": "stainless"})
283 assert _get_params(copied)["foo"] == "stainless"
284
285 # set_default_query
286
287 # completely overrides already set values
288 copied = client.copy(set_default_query={})
289 assert _get_params(copied) == {}
290
291 copied = client.copy(set_default_query={"bar": "Robert"})
292 assert _get_params(copied)["bar"] == "Robert"
293
294 with pytest.raises(
295 ValueError,
296 # TODO: update
297 match="`default_query` and `set_default_query` arguments are mutually exclusive",
298 ):
299 client.copy(set_default_query={}, default_query={"foo": "Bar"})
300
301 client.close()
302
303 def test_copy_signature(self, client: Anthropic) -> None:
304 # 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