From 983ac44a70a096d77aa7644adf735fe1b787fd9d Mon Sep 17 00:00:00 2001 From: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com> Date: Thu, 11 Sep 2025 18:45:07 -0700 Subject: [PATCH] Small test fixes --- python/packages/azure/tests/conftest.py | 18 +++++++++--------- .../tests/test_azure_assistants_client.py | 2 +- .../azure/tests/test_azure_chat_client.py | 10 +++++----- .../azure/tests/test_azure_responses_client.py | 2 +- python/packages/copilotstudio/README.md | 4 ++-- .../packages/copilotstudio/tests/conftest.py | 18 +++++++++--------- python/packages/foundry/tests/conftest.py | 18 +++++++++--------- .../foundry/tests/test_foundry_chat_client.py | 2 +- python/packages/main/tests/openai/conftest.py | 18 +++++++++--------- .../openai/test_openai_assistants_client.py | 4 ++-- .../tests/openai/test_openai_chat_client.py | 4 ++-- .../openai/test_openai_responses_client.py | 4 ++-- .../agents/copilotstudio/README.md | 4 ++-- 13 files changed, 54 insertions(+), 54 deletions(-) diff --git a/python/packages/azure/tests/conftest.py b/python/packages/azure/tests/conftest.py index 28349f15df..f821587ea6 100644 --- a/python/packages/azure/tests/conftest.py +++ b/python/packages/azure/tests/conftest.py @@ -7,27 +7,27 @@ from pytest import fixture # region: Connector Settings fixtures @fixture -def exclude_list(request: Any) -> list[str]: +def azure_exclude_list(request: Any) -> list[str]: """Fixture that returns a list of environment variables to exclude.""" return request.param if hasattr(request, "param") else [] @fixture -def override_env_param_dict(request: Any) -> dict[str, str]: +def azure_override_env_param_dict(request: Any) -> dict[str, str]: """Fixture that returns a dict of environment variables to override.""" return request.param if hasattr(request, "param") else {} # These two fixtures are used for multiple things, also non-connector tests @fixture() -def azure_openai_unit_test_env(monkeypatch, exclude_list, override_env_param_dict): # type: ignore +def azure_openai_unit_test_env(monkeypatch, azure_exclude_list, azure_override_env_param_dict): # type: ignore """Fixture to set environment variables for AzureOpenAISettings.""" - if exclude_list is None: - exclude_list = [] + if azure_exclude_list is None: + azure_exclude_list = [] - if override_env_param_dict is None: - override_env_param_dict = {} + if azure_override_env_param_dict is None: + azure_override_env_param_dict = {} env_vars = { "AZURE_OPENAI_ENDPOINT": "https://test-endpoint.com", @@ -45,10 +45,10 @@ def azure_openai_unit_test_env(monkeypatch, exclude_list, override_env_param_dic "AZURE_OPENAI_TOKEN_ENDPOINT": "https://test-token-endpoint.com", } - env_vars.update(override_env_param_dict) # type: ignore + env_vars.update(azure_override_env_param_dict) # type: ignore for key, value in env_vars.items(): - if key in exclude_list: + if key in azure_exclude_list: monkeypatch.delenv(key, raising=False) # type: ignore continue monkeypatch.setenv(key, value) # type: ignore diff --git a/python/packages/azure/tests/test_azure_assistants_client.py b/python/packages/azure/tests/test_azure_assistants_client.py index 7bd2f6571b..df48297d20 100644 --- a/python/packages/azure/tests/test_azure_assistants_client.py +++ b/python/packages/azure/tests/test_azure_assistants_client.py @@ -125,7 +125,7 @@ def test_azure_assistants_client_init_validation_fail() -> None: AzureAssistantsClient(deployment_name=123, api_key="valid-key") # type: ignore -@pytest.mark.parametrize("exclude_list", [["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"]], indirect=True) +@pytest.mark.parametrize("azure_exclude_list", [["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"]], indirect=True) def test_azure_assistants_client_init_missing_deployment_name(azure_openai_unit_test_env: dict[str, str]) -> None: """Test AzureAssistantsClient initialization with missing deployment name.""" with pytest.raises(ServiceInitializationError): diff --git a/python/packages/azure/tests/test_azure_chat_client.py b/python/packages/azure/tests/test_azure_chat_client.py index b4669d1ec0..1c5f83ca62 100644 --- a/python/packages/azure/tests/test_azure_chat_client.py +++ b/python/packages/azure/tests/test_azure_chat_client.py @@ -83,7 +83,7 @@ def test_init_base_url(azure_openai_unit_test_env: dict[str, str]) -> None: assert azure_chat_client.client.default_headers[key] == value -@pytest.mark.parametrize("exclude_list", [["AZURE_OPENAI_BASE_URL"]], indirect=True) +@pytest.mark.parametrize("azure_exclude_list", [["AZURE_OPENAI_BASE_URL"]], indirect=True) def test_init_endpoint(azure_openai_unit_test_env: dict[str, str]) -> None: azure_chat_client = AzureChatClient() @@ -93,7 +93,7 @@ def test_init_endpoint(azure_openai_unit_test_env: dict[str, str]) -> None: assert isinstance(azure_chat_client, BaseChatClient) -@pytest.mark.parametrize("exclude_list", [["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"]], indirect=True) +@pytest.mark.parametrize("azure_exclude_list", [["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"]], indirect=True) def test_init_with_empty_deployment_name(azure_openai_unit_test_env: dict[str, str]) -> None: with pytest.raises(ServiceInitializationError): AzureChatClient( @@ -101,7 +101,7 @@ def test_init_with_empty_deployment_name(azure_openai_unit_test_env: dict[str, s ) -@pytest.mark.parametrize("exclude_list", [["AZURE_OPENAI_ENDPOINT", "AZURE_OPENAI_BASE_URL"]], indirect=True) +@pytest.mark.parametrize("azure_exclude_list", [["AZURE_OPENAI_ENDPOINT", "AZURE_OPENAI_BASE_URL"]], indirect=True) def test_init_with_empty_endpoint_and_base_url(azure_openai_unit_test_env: dict[str, str]) -> None: with pytest.raises(ServiceInitializationError): AzureChatClient( @@ -109,13 +109,13 @@ def test_init_with_empty_endpoint_and_base_url(azure_openai_unit_test_env: dict[ ) -@pytest.mark.parametrize("override_env_param_dict", [{"AZURE_OPENAI_ENDPOINT": "http://test.com"}], indirect=True) +@pytest.mark.parametrize("azure_override_env_param_dict", [{"AZURE_OPENAI_ENDPOINT": "http://test.com"}], indirect=True) def test_init_with_invalid_endpoint(azure_openai_unit_test_env: dict[str, str]) -> None: with pytest.raises(ServiceInitializationError): AzureChatClient() -@pytest.mark.parametrize("exclude_list", [["AZURE_OPENAI_BASE_URL"]], indirect=True) +@pytest.mark.parametrize("azure_exclude_list", [["AZURE_OPENAI_BASE_URL"]], indirect=True) def test_serialize(azure_openai_unit_test_env: dict[str, str]) -> None: default_headers = {"X-Test": "test"} diff --git a/python/packages/azure/tests/test_azure_responses_client.py b/python/packages/azure/tests/test_azure_responses_client.py index 2e02989478..e2df3e19b3 100644 --- a/python/packages/azure/tests/test_azure_responses_client.py +++ b/python/packages/azure/tests/test_azure_responses_client.py @@ -85,7 +85,7 @@ def test_init_with_default_header(azure_openai_unit_test_env: dict[str, str]) -> assert azure_responses_client.client.default_headers[key] == value -@pytest.mark.parametrize("exclude_list", [["AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME"]], indirect=True) +@pytest.mark.parametrize("azure_exclude_list", [["AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME"]], indirect=True) def test_init_with_empty_model_id(azure_openai_unit_test_env: dict[str, str]) -> None: with pytest.raises(ServiceInitializationError): AzureResponsesClient( diff --git a/python/packages/copilotstudio/README.md b/python/packages/copilotstudio/README.md index a02c9effd9..fcf211a919 100644 --- a/python/packages/copilotstudio/README.md +++ b/python/packages/copilotstudio/README.md @@ -31,7 +31,7 @@ The following environment variables are used for configuration: ```python import asyncio -from agent_framework_copilotstudio import CopilotStudioAgent +from agent_framework.copilotstudio import CopilotStudioAgent async def main(): # Create agent using environment variables @@ -49,7 +49,7 @@ asyncio.run(main()) ```python import asyncio import os -from agent_framework_copilotstudio import CopilotStudioAgent, acquire_token +from agent_framework.copilotstudio import CopilotStudioAgent, acquire_token from microsoft_agents.copilotstudio.client import ConnectionSettings, CopilotClient, PowerPlatformCloud, AgentType async def main(): diff --git a/python/packages/copilotstudio/tests/conftest.py b/python/packages/copilotstudio/tests/conftest.py index b836a5e71a..8869f79ca9 100644 --- a/python/packages/copilotstudio/tests/conftest.py +++ b/python/packages/copilotstudio/tests/conftest.py @@ -8,26 +8,26 @@ from microsoft_agents.copilotstudio.client import CopilotClient @pytest.fixture -def exclude_list(request: Any) -> list[str]: +def copilot_studio_exclude_list(request: Any) -> list[str]: """Fixture that returns a list of environment variables to exclude.""" return request.param if hasattr(request, "param") else [] @pytest.fixture -def override_env_param_dict(request: Any) -> dict[str, str]: +def copilot_studio_override_env_param_dict(request: Any) -> dict[str, str]: """Fixture that returns a dict of environment variables to override.""" return request.param if hasattr(request, "param") else {} @pytest.fixture() -def copilot_studio_unit_test_env(monkeypatch, exclude_list, override_env_param_dict): # type: ignore +def copilot_studio_unit_test_env(monkeypatch, copilot_studio_exclude_list, copilot_studio_override_env_param_dict): # type: ignore """Fixture to set environment variables for CopilotStudioSettings.""" - if exclude_list is None: - exclude_list = [] + if copilot_studio_exclude_list is None: + copilot_studio_exclude_list = [] - if override_env_param_dict is None: - override_env_param_dict = {} + if copilot_studio_override_env_param_dict is None: + copilot_studio_override_env_param_dict = {} env_vars = { "COPILOTSTUDIOAGENT__ENVIRONMENTID": "test-environment-id", @@ -36,10 +36,10 @@ def copilot_studio_unit_test_env(monkeypatch, exclude_list, override_env_param_d "COPILOTSTUDIOAGENT__TENANTID": "test-tenant-id", } - env_vars.update(override_env_param_dict) # type: ignore + env_vars.update(copilot_studio_override_env_param_dict) # type: ignore for key, value in env_vars.items(): - if key in exclude_list: + if key in copilot_studio_exclude_list: monkeypatch.delenv(key, raising=False) # type: ignore continue monkeypatch.setenv(key, value) # type: ignore diff --git a/python/packages/foundry/tests/conftest.py b/python/packages/foundry/tests/conftest.py index eb858f7a1b..059ef2b17e 100644 --- a/python/packages/foundry/tests/conftest.py +++ b/python/packages/foundry/tests/conftest.py @@ -6,26 +6,26 @@ from pytest import fixture @fixture -def exclude_list(request: Any) -> list[str]: +def foundry_exclude_list(request: Any) -> list[str]: """Fixture that returns a list of environment variables to exclude.""" return request.param if hasattr(request, "param") else [] @fixture -def override_env_param_dict(request: Any) -> dict[str, str]: +def foundry_override_env_param_dict(request: Any) -> dict[str, str]: """Fixture that returns a dict of environment variables to override.""" return request.param if hasattr(request, "param") else {} @fixture() -def foundry_unit_test_env(monkeypatch, exclude_list, override_env_param_dict): # type: ignore +def foundry_unit_test_env(monkeypatch, foundry_exclude_list, foundry_override_env_param_dict): # type: ignore """Fixture to set environment variables for FoundrySettings.""" - if exclude_list is None: - exclude_list = [] + if foundry_exclude_list is None: + foundry_exclude_list = [] - if override_env_param_dict is None: - override_env_param_dict = {} + if foundry_override_env_param_dict is None: + foundry_override_env_param_dict = {} env_vars = { "FOUNDRY_PROJECT_ENDPOINT": "https://test-project.cognitiveservices.azure.com/", @@ -33,10 +33,10 @@ def foundry_unit_test_env(monkeypatch, exclude_list, override_env_param_dict): "FOUNDRY_AGENT_NAME": "TestAgent", } - env_vars.update(override_env_param_dict) # type: ignore + env_vars.update(foundry_override_env_param_dict) # type: ignore for key, value in env_vars.items(): - if key in exclude_list: + if key in foundry_exclude_list: monkeypatch.delenv(key, raising=False) # type: ignore continue monkeypatch.setenv(key, value) # type: ignore diff --git a/python/packages/foundry/tests/test_foundry_chat_client.py b/python/packages/foundry/tests/test_foundry_chat_client.py index 8a7eec03b6..936ff33116 100644 --- a/python/packages/foundry/tests/test_foundry_chat_client.py +++ b/python/packages/foundry/tests/test_foundry_chat_client.py @@ -294,7 +294,7 @@ async def test_foundry_chat_client_thread_management_through_public_api(mock_ai_ mock_ai_project_client.agents.threads.create.assert_called_once() -@pytest.mark.parametrize("exclude_list", [["FOUNDRY_MODEL_DEPLOYMENT_NAME"]], indirect=True) +@pytest.mark.parametrize("foundry_exclude_list", [["FOUNDRY_MODEL_DEPLOYMENT_NAME"]], indirect=True) async def test_foundry_chat_client_get_agent_id_or_create_missing_model( mock_ai_project_client: MagicMock, foundry_unit_test_env: dict[str, str] ) -> None: diff --git a/python/packages/main/tests/openai/conftest.py b/python/packages/main/tests/openai/conftest.py index 7bedccd52d..ee20323a26 100644 --- a/python/packages/main/tests/openai/conftest.py +++ b/python/packages/main/tests/openai/conftest.py @@ -8,26 +8,26 @@ from agent_framework.telemetry import OtelSettings, setup_telemetry # region Connector Settings fixtures @fixture -def exclude_list(request: Any) -> list[str]: +def openai_exclude_list(request: Any) -> list[str]: """Fixture that returns a list of environment variables to exclude.""" return request.param if hasattr(request, "param") else [] @fixture -def override_env_param_dict(request: Any) -> dict[str, str]: +def openai_override_env_param_dict(request: Any) -> dict[str, str]: """Fixture that returns a dict of environment variables to override.""" return request.param if hasattr(request, "param") else {} @fixture() -def openai_unit_test_env(monkeypatch, exclude_list, override_env_param_dict): # type: ignore +def openai_unit_test_env(monkeypatch, openai_exclude_list, openai_override_env_param_dict): # type: ignore """Fixture to set environment variables for OpenAISettings.""" - if exclude_list is None: - exclude_list = [] + if openai_exclude_list is None: + openai_exclude_list = [] - if override_env_param_dict is None: - override_env_param_dict = {} + if openai_override_env_param_dict is None: + openai_override_env_param_dict = {} env_vars = { "OPENAI_API_KEY": "test-dummy-key", @@ -42,10 +42,10 @@ def openai_unit_test_env(monkeypatch, exclude_list, override_env_param_dict): # "OPENAI_REALTIME_MODEL_ID": "test_realtime_model_id", } - env_vars.update(override_env_param_dict) # type: ignore + env_vars.update(openai_override_env_param_dict) # type: ignore for key, value in env_vars.items(): - if key in exclude_list: + if key in openai_exclude_list: monkeypatch.delenv(key, raising=False) # type: ignore continue monkeypatch.setenv(key, value) # type: ignore diff --git a/python/packages/main/tests/openai/test_openai_assistants_client.py b/python/packages/main/tests/openai/test_openai_assistants_client.py index 76ce1ce87e..863d1697f8 100644 --- a/python/packages/main/tests/openai/test_openai_assistants_client.py +++ b/python/packages/main/tests/openai/test_openai_assistants_client.py @@ -158,7 +158,7 @@ def test_openai_assistants_client_init_validation_fail() -> None: OpenAIAssistantsClient(ai_model_id=123, api_key="valid-key") # type: ignore -@pytest.mark.parametrize("exclude_list", [["OPENAI_CHAT_MODEL_ID"]], indirect=True) +@pytest.mark.parametrize("openai_exclude_list", [["OPENAI_CHAT_MODEL_ID"]], indirect=True) def test_openai_assistants_client_init_missing_model_id(openai_unit_test_env: dict[str, str]) -> None: """Test OpenAIAssistantsClient initialization with missing model ID.""" with pytest.raises(ServiceInitializationError): @@ -167,7 +167,7 @@ def test_openai_assistants_client_init_missing_model_id(openai_unit_test_env: di ) -@pytest.mark.parametrize("exclude_list", [["OPENAI_API_KEY"]], indirect=True) +@pytest.mark.parametrize("openai_exclude_list", [["OPENAI_API_KEY"]], indirect=True) def test_openai_assistants_client_init_missing_api_key(openai_unit_test_env: dict[str, str]) -> None: """Test OpenAIAssistantsClient initialization with missing API key.""" with pytest.raises(ServiceInitializationError): diff --git a/python/packages/main/tests/openai/test_openai_chat_client.py b/python/packages/main/tests/openai/test_openai_chat_client.py index f57af48207..42b2b3069f 100644 --- a/python/packages/main/tests/openai/test_openai_chat_client.py +++ b/python/packages/main/tests/openai/test_openai_chat_client.py @@ -80,7 +80,7 @@ def test_init_base_url(openai_unit_test_env: dict[str, str]) -> None: assert str(open_ai_chat_completion.client.base_url) == "http://localhost:1234/v1/" -@pytest.mark.parametrize("exclude_list", [["OPENAI_CHAT_MODEL_ID"]], indirect=True) +@pytest.mark.parametrize("openai_exclude_list", [["OPENAI_CHAT_MODEL_ID"]], indirect=True) def test_init_with_empty_model_id(openai_unit_test_env: dict[str, str]) -> None: with pytest.raises(ServiceInitializationError): OpenAIChatClient( @@ -88,7 +88,7 @@ def test_init_with_empty_model_id(openai_unit_test_env: dict[str, str]) -> None: ) -@pytest.mark.parametrize("exclude_list", [["OPENAI_API_KEY"]], indirect=True) +@pytest.mark.parametrize("openai_exclude_list", [["OPENAI_API_KEY"]], indirect=True) def test_init_with_empty_api_key(openai_unit_test_env: dict[str, str]) -> None: ai_model_id = "test_model_id" diff --git a/python/packages/main/tests/openai/test_openai_responses_client.py b/python/packages/main/tests/openai/test_openai_responses_client.py index 4f2846a981..4ae0f8756e 100644 --- a/python/packages/main/tests/openai/test_openai_responses_client.py +++ b/python/packages/main/tests/openai/test_openai_responses_client.py @@ -125,7 +125,7 @@ def test_init_with_default_header(openai_unit_test_env: dict[str, str]) -> None: assert openai_responses_client.client.default_headers[key] == value -@pytest.mark.parametrize("exclude_list", [["OPENAI_RESPONSES_MODEL_ID"]], indirect=True) +@pytest.mark.parametrize("openai_exclude_list", [["OPENAI_RESPONSES_MODEL_ID"]], indirect=True) def test_init_with_empty_model_id(openai_unit_test_env: dict[str, str]) -> None: with pytest.raises(ServiceInitializationError): OpenAIResponsesClient( @@ -133,7 +133,7 @@ def test_init_with_empty_model_id(openai_unit_test_env: dict[str, str]) -> None: ) -@pytest.mark.parametrize("exclude_list", [["OPENAI_API_KEY"]], indirect=True) +@pytest.mark.parametrize("openai_exclude_list", [["OPENAI_API_KEY"]], indirect=True) def test_init_with_empty_api_key(openai_unit_test_env: dict[str, str]) -> None: ai_model_id = "test_model_id" diff --git a/python/samples/getting_started/agents/copilotstudio/README.md b/python/samples/getting_started/agents/copilotstudio/README.md index bc862b6cb3..e2503db51a 100644 --- a/python/samples/getting_started/agents/copilotstudio/README.md +++ b/python/samples/getting_started/agents/copilotstudio/README.md @@ -45,7 +45,7 @@ Your Azure AD App Registration should have: ### Basic Usage with Environment Variables ```python -from agent_framework_copilotstudio import CopilotStudioAgent +from agent_framework.copilotstudio import CopilotStudioAgent # Uses environment variables for configuration agent = CopilotStudioAgent() @@ -55,7 +55,7 @@ result = await agent.run("What is the capital of France?") ### Explicit Configuration ```python -from agent_framework_copilotstudio import CopilotStudioAgent, acquire_token +from agent_framework.copilotstudio import CopilotStudioAgent, acquire_token from microsoft_agents.copilotstudio.client import ConnectionSettings, CopilotClient, PowerPlatformCloud, AgentType # Acquire token manually