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

Method test_copy_default_query

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

Source from the content-addressed store, hash-verified

226 client.close()
227
228 def test_copy_default_query(self) -> None:
229 client = Anthropic(
230 base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"foo": "bar"}
231 )
232 assert _get_params(client)["foo"] == "bar"
233
234 # does not override the already given value when not specified
235 copied = client.copy()
236 assert _get_params(copied)["foo"] == "bar"
237
238 # merges already given params
239 copied = client.copy(default_query={"bar": "stainless"})
240 params = _get_params(copied)
241 assert params["foo"] == "bar"
242 assert params["bar"] == "stainless"
243
244 # uses new values for any already given headers
245 copied = client.copy(default_query={"foo": "stainless"})
246 assert _get_params(copied)["foo"] == "stainless"
247
248 # set_default_query
249
250 # completely overrides already set values
251 copied = client.copy(set_default_query={})
252 assert _get_params(copied) == {}
253
254 copied = client.copy(set_default_query={"bar": "Robert"})
255 assert _get_params(copied)["bar"] == "Robert"
256
257 with pytest.raises(
258 ValueError,
259 # TODO: update
260 match="`default_query` and `set_default_query` arguments are mutually exclusive",
261 ):
262 client.copy(set_default_query={}, default_query={"foo": "Bar"})
263
264 client.close()
265
266 def test_copy_signature(self, client: Anthropic) -> None:
267 # 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