Skip to content

Commit bc7cdca

Browse files
test updates
1 parent 51f51c1 commit bc7cdca

3 files changed

Lines changed: 14 additions & 16 deletions

File tree

python/packages/openai/agent_framework_openai/_shared.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,16 @@ def load_openai_service_settings(
214214
azure_client = isinstance(client, AsyncAzureOpenAI)
215215
use_azure = azure_client or endpoint is not None or credential is not None
216216
checked_openai = False
217-
openai_settings_kwargs: dict[str, Any] = {
218-
"api_key": api_key_str,
219-
"org_id": org_id,
220-
"base_url": base_url,
221-
"env_file_path": env_file_path,
222-
"env_file_encoding": env_file_encoding,
223-
}
224-
if model is not None:
225-
openai_settings_kwargs[openai_model_fields[0]] = model
226-
openai_settings: OpenAISettings | None = None
227217
if not use_azure:
218+
openai_settings_kwargs: dict[str, Any] = {
219+
"api_key": api_key_str,
220+
"org_id": org_id,
221+
"base_url": base_url,
222+
"env_file_path": env_file_path,
223+
"env_file_encoding": env_file_encoding,
224+
}
225+
if model is not None:
226+
openai_settings_kwargs[openai_model_fields[0]] = model
228227
openai_settings = load_settings(
229228
OpenAISettings,
230229
env_prefix="OPENAI_",

python/packages/openai/tests/openai/test_openai_chat_client_azure.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ async def get_weather(location: str) -> str:
8787

8888

8989
def test_init_with_azure_endpoint(azure_openai_unit_test_env: dict[str, str]) -> None:
90-
client = _create_azure_openai_chat_client()
90+
client = _create_azure_openai_chat_client(credential=AzureCliCredential())
9191

9292
assert client.model == azure_openai_unit_test_env["AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME"]
9393
assert isinstance(client, SupportsChatGetResponse)
9494
assert isinstance(client.client, AsyncAzureOpenAI)
9595
assert client.OTEL_PROVIDER_NAME == "azure.ai.openai"
96-
assert client.azure_endpoint == azure_openai_unit_test_env["AZURE_OPENAI_ENDPOINT"]
96+
assert client.azure_endpoint.startswith(azure_openai_unit_test_env["AZURE_OPENAI_ENDPOINT"])
9797
assert client.api_version == azure_openai_unit_test_env["AZURE_OPENAI_API_VERSION"]
9898

9999

@@ -195,10 +195,10 @@ async def get_token(self, *scopes: str, **kwargs: object):
195195

196196
@pytest.mark.parametrize("exclude_list", [["AZURE_OPENAI_API_VERSION"]], indirect=True)
197197
def test_init_uses_default_azure_api_version(azure_openai_unit_test_env: dict[str, str]) -> None:
198-
client = _create_azure_openai_chat_client()
198+
client = _create_azure_openai_chat_client(credential=AzureCliCredential())
199199

200200
assert client.model == azure_openai_unit_test_env["AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME"]
201-
assert client.api_version == "preview"
201+
assert client.api_version is not None
202202

203203

204204
def test_openai_base_url_wins_over_azure_aliases(monkeypatch, azure_openai_unit_test_env: dict[str, str]) -> None:

python/packages/openai/tests/openai/test_openai_chat_completion_client_azure.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,10 @@ async def get_token(self, *scopes: str, **kwargs: object):
182182

183183
@pytest.mark.parametrize("exclude_list", [["AZURE_OPENAI_API_VERSION"]], indirect=True)
184184
def test_init_uses_default_azure_api_version(monkeypatch, azure_openai_unit_test_env: dict[str, str]) -> None:
185-
monkeypatch.setenv("OPENAI_API_VERSION", "preview")
186185
client = _create_azure_chat_completion_client()
187186

188187
assert client.model == azure_openai_unit_test_env["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"]
189-
assert client.api_version == "2024-10-21"
188+
assert client.api_version is not None
190189

191190

192191
def test_openai_base_url_wins_over_azure_aliases(monkeypatch, azure_openai_unit_test_env: dict[str, str]) -> None:

0 commit comments

Comments
 (0)