MCPcopy
hub / github.com/openai/openai-python / test_copy_default_query

Method test_copy_default_query

tests/test_client.py:1477–1517  ·  tests/test_client.py::TestAsyncOpenAI.test_copy_default_query
(self)

Source from the content-addressed store, hash-verified

1475 await client.close()
1476
1477 async def test_copy_default_query(self) -> None:
1478 client = AsyncOpenAI(
1479 base_url=base_url,
1480 api_key=api_key,
1481 admin_api_key=admin_api_key,
1482 _strict_response_validation=True,
1483 default_query={class="st">"foo": class="st">"bar"},
1484 )
1485 assert _get_params(client)[class="st">"foo"] == class="st">"bar"
1486
1487 class="cm"># does not override the already given value when not specified
1488 copied = client.copy()
1489 assert _get_params(copied)[class="st">"foo"] == class="st">"bar"
1490
1491 class="cm"># merges already given params
1492 copied = client.copy(default_query={class="st">"bar": class="st">"stainless"})
1493 params = _get_params(copied)
1494 assert params[class="st">"foo"] == class="st">"bar"
1495 assert params[class="st">"bar"] == class="st">"stainless"
1496
1497 class="cm"># uses new values for any already given headers
1498 copied = client.copy(default_query={class="st">"foo": class="st">"stainless"})
1499 assert _get_params(copied)[class="st">"foo"] == class="st">"stainless"
1500
1501 class="cm"># set_default_query
1502
1503 class="cm"># completely overrides already set values
1504 copied = client.copy(set_default_query={})
1505 assert _get_params(copied) == {}
1506
1507 copied = client.copy(set_default_query={class="st">"bar": class="st">"Robert"})
1508 assert _get_params(copied)[class="st">"bar"] == class="st">"Robert"
1509
1510 with pytest.raises(
1511 ValueError,
1512 class="cm"># TODO: update
1513 match=class="st">"`default_query` and `set_default_query` arguments are mutually exclusive",
1514 ):
1515 client.copy(set_default_query={}, default_query={class="st">"foo": class="st">"Bar"})
1516
1517 await client.close()
1518
1519 def test_copy_signature(self, async_client: AsyncOpenAI) -> None:
1520 class="cm"># 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
AsyncOpenAIClass · 0.90
_get_paramsFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected