Skip to content

Commit 32d2ce4

Browse files
updated test file
1 parent 7910fed commit 32d2ce4

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

src/App/tests/backend/plugins/test_chat_with_data_plugin.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,35 @@ def setup_method(self):
1313
self.plugin = ChatWithDataPlugin()
1414

1515
@patch("backend.plugins.chat_with_data_plugin.config")
16-
@patch("backend.plugins.chat_with_data_plugin.openai.AzureOpenAI")
17-
@patch("backend.plugins.chat_with_data_plugin.get_bearer_token_provider")
16+
@patch("backend.plugins.chat_with_data_plugin.AIProjectClient")
1817
@patch("backend.plugins.chat_with_data_plugin.get_azure_credential")
19-
def test_get_openai_client_success(
20-
self,
21-
mock_default_credential,
22-
mock_token_provider,
23-
mock_azure_openai,
24-
mock_config,
18+
def test_get_project_openai_client_success_updated(
19+
self, mock_default_credential, mock_ai_project_client, mock_config
2520
):
26-
"""Test successful creation of OpenAI client with AAD authentication."""
21+
"""Test successful creation of project OpenAI client after removing direct OpenAI client method."""
2722
# Mock config values
28-
mock_config.AZURE_OPENAI_ENDPOINT = "https://test.openai.azure.com"
23+
mock_config.AI_PROJECT_ENDPOINT = "https://test.ai.azure.com"
2924
mock_config.AZURE_OPENAI_PREVIEW_API_VERSION = "2025-04-01-preview"
3025

31-
mock_client = MagicMock()
32-
mock_azure_openai.return_value = mock_client
3326
mock_credential = MagicMock()
3427
mock_default_credential.return_value = mock_credential
35-
mock_token = MagicMock()
36-
mock_token_provider.return_value = mock_token
3728

38-
result = self.plugin.get_openai_client()
29+
mock_project_instance = MagicMock()
30+
mock_openai_client = MagicMock()
31+
mock_project_instance.inference.get_azure_openai_client.return_value = (
32+
mock_openai_client
33+
)
34+
mock_ai_project_client.return_value = mock_project_instance
35+
36+
result = self.plugin.get_project_openai_client()
3937

40-
assert result == mock_client
38+
assert result == mock_openai_client
4139
mock_default_credential.assert_called_once()
42-
mock_token_provider.assert_called_once_with(
43-
mock_credential, "https://cognitiveservices.azure.com/.default"
40+
mock_ai_project_client.assert_called_once_with(
41+
endpoint="https://test.ai.azure.com", credential=mock_credential
4442
)
45-
mock_azure_openai.assert_called_once_with(
46-
azure_endpoint="https://test.openai.azure.com",
47-
azure_ad_token_provider=mock_token,
48-
api_version="2025-04-01-preview",
43+
mock_project_instance.inference.get_azure_openai_client.assert_called_once_with(
44+
api_version="2025-04-01-preview"
4945
)
5046

5147
@patch("backend.plugins.chat_with_data_plugin.config")

0 commit comments

Comments
 (0)