Skip to content

Commit a5e06d8

Browse files
committed
Remove user-agent construction tests for sync and async clients
1 parent ccaea9e commit a5e06d8

2 files changed

Lines changed: 0 additions & 81 deletions

File tree

sdk/ai/azure-ai-projects/tests/responses/test_openai_client_overrides.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -201,43 +201,3 @@ def test_console_logging_creates_logging_transport(self):
201201
mock_httpx.Client.return_value = object()
202202
client.get_openai_client()
203203
mock_httpx.Client.assert_called_once()
204-
205-
206-
# ===========================================================================
207-
# User-Agent construction branches
208-
# ===========================================================================
209-
210-
211-
class TestUserAgentBranches:
212-
def test_caller_user_agent_used_verbatim(self):
213-
"""Branch: 'User-Agent' in default_headers -> use as-is."""
214-
client = make_sync_client()
215-
mock_cls, _ = mock_openai("openai/sdk-ua")
216-
with patch(SYNC_OPENAI_PATCH, mock_cls), patch(SYNC_TOKEN_PROVIDER_PATCH, return_value="tok"):
217-
client.get_openai_client(default_headers={"User-Agent": "MyApp/1.0"})
218-
real_call = mock_cls.call_args_list[-1]
219-
assert real_call.kwargs["default_headers"]["User-Agent"] == "MyApp/1.0"
220-
221-
def test_sdk_user_agent_without_custom_prefix(self):
222-
"""Branch: no caller UA, no _custom_user_agent -> 'AIProjectClient <openai_ua>'."""
223-
client = make_sync_client(custom_user_agent=None)
224-
openai_ua = "openai/1.2.3"
225-
mock_cls, _ = mock_openai(openai_ua)
226-
with patch(SYNC_OPENAI_PATCH, mock_cls), patch(SYNC_TOKEN_PROVIDER_PATCH, return_value="tok"):
227-
client.get_openai_client()
228-
real_call = mock_cls.call_args_list[-1]
229-
ua = real_call.kwargs["default_headers"]["User-Agent"]
230-
assert "AIProjectClient" in ua
231-
assert openai_ua in ua
232-
233-
def test_sdk_user_agent_with_custom_prefix(self):
234-
"""Branch: no caller UA, _custom_user_agent set -> 'custom-AIProjectClient <openai_ua>'."""
235-
client = make_sync_client(custom_user_agent="MySDK")
236-
openai_ua = "openai/1.2.3"
237-
mock_cls, _ = mock_openai(openai_ua)
238-
with patch(SYNC_OPENAI_PATCH, mock_cls), patch(SYNC_TOKEN_PROVIDER_PATCH, return_value="tok"):
239-
client.get_openai_client()
240-
real_call = mock_cls.call_args_list[-1]
241-
ua = real_call.kwargs["default_headers"]["User-Agent"]
242-
assert ua.startswith("MySDK-AIProjectClient")
243-
assert openai_ua in ua

sdk/ai/azure-ai-projects/tests/responses/test_openai_client_overrides_async.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -212,44 +212,3 @@ async def test_console_logging_creates_async_logging_transport(self):
212212
mock_httpx.AsyncClient.return_value = object()
213213
client.get_openai_client()
214214
mock_httpx.AsyncClient.assert_called_once()
215-
216-
217-
# ===========================================================================
218-
# User-Agent construction branches (async)
219-
# ===========================================================================
220-
221-
222-
class TestUserAgentBranchesAsync:
223-
@pytest.mark.asyncio
224-
async def test_caller_user_agent_used_verbatim(self):
225-
"""Branch: 'User-Agent' in default_headers -> use as-is."""
226-
client = make_async_client()
227-
mock_cls, _ = mock_openai("openai/x")
228-
with patch(ASYNC_OPENAI_PATCH, mock_cls), patch(ASYNC_TOKEN_PROVIDER_PATCH, return_value="tok"):
229-
client.get_openai_client(default_headers={"User-Agent": "AsyncApp/2.0"})
230-
real_call = mock_cls.call_args_list[-1]
231-
assert real_call.kwargs["default_headers"]["User-Agent"] == "AsyncApp/2.0"
232-
233-
@pytest.mark.asyncio
234-
async def test_sdk_user_agent_built_without_custom_prefix(self):
235-
"""Branch: no caller UA, no _custom_user_agent -> 'AIProjectClient <openai_ua>'."""
236-
client = make_async_client(custom_user_agent=None)
237-
mock_cls, _ = mock_openai("openai/async-sdk")
238-
with patch(ASYNC_OPENAI_PATCH, mock_cls), patch(ASYNC_TOKEN_PROVIDER_PATCH, return_value="tok"):
239-
client.get_openai_client()
240-
real_call = mock_cls.call_args_list[-1]
241-
ua = real_call.kwargs["default_headers"]["User-Agent"]
242-
assert "AIProjectClient" in ua
243-
assert "openai/async-sdk" in ua
244-
245-
@pytest.mark.asyncio
246-
async def test_sdk_user_agent_with_custom_prefix(self):
247-
"""Branch: no caller UA, _custom_user_agent set -> 'custom-AIProjectClient <openai_ua>'."""
248-
client = make_async_client(custom_user_agent="MyAsyncSDK")
249-
mock_cls, _ = mock_openai("openai/async-sdk")
250-
with patch(ASYNC_OPENAI_PATCH, mock_cls), patch(ASYNC_TOKEN_PROVIDER_PATCH, return_value="tok"):
251-
client.get_openai_client()
252-
real_call = mock_cls.call_args_list[-1]
253-
ua = real_call.kwargs["default_headers"]["User-Agent"]
254-
assert ua.startswith("MyAsyncSDK-AIProjectClient")
255-
assert "openai/async-sdk" in ua

0 commit comments

Comments
 (0)