@@ -155,23 +155,24 @@ async def test_get_SQL_Response(self, mock_azure_openai, mock_execute_sql, mock_
155155 mock_execute_sql .assert_called_once_with ("SELECT * FROM km_processed_data" )
156156
157157 @pytest .mark .asyncio
158- @patch ("helpers.azure_openai_helper .Config" )
158+ @patch ("plugins.chat_with_data_plugin .Config" )
159159 @patch ("plugins.chat_with_data_plugin.execute_sql_query" )
160160 @patch ("plugins.chat_with_data_plugin.AIProjectClient" )
161161 @patch ("plugins.chat_with_data_plugin.DefaultAzureCredential" )
162- async def test_get_SQL_Response_with_ai_project_client (self , mock_azure_credential , mock_ai_project_client , mock_execute_sql , chat_plugin ):
162+ async def test_get_SQL_Response_with_ai_project_client (self , mock_azure_credential , mock_ai_project_client , mock_execute_sql , mock_config , chat_plugin ):
163163 # Setup AIProjectClient
164164 chat_plugin .use_ai_project_client = True
165165
166166 # Setup mocks
167167 mock_config_instance = MagicMock ()
168168 mock_config_instance .ai_project_endpoint = "https://test-openai.azure.com/"
169169 mock_config .return_value = mock_config_instance
170- mock_project = MagicMock ()
171- mock_ai_project_client = MagicMock ()
172- mock_ai_project_client .return_value = mock_project
170+ mock_credential_instance = MagicMock ()
171+ mock_azure_credential .return_value = mock_credential_instance
172+ mock_project_instance = MagicMock ()
173+ mock_ai_project_client .return_value = mock_project_instance
173174 mock_client = MagicMock ()
174- mock_project .inference .get_chat_completions_client .return_value = mock_client
175+ mock_project_instance .inference .get_chat_completions_client .return_value = mock_client
175176 mock_completion = MagicMock ()
176177 mock_completion .choices = [MagicMock ()]
177178 mock_completion .choices [0 ].message .content = "```sql\n SELECT * FROM km_processed_data\n ```"
@@ -184,9 +185,9 @@ async def test_get_SQL_Response_with_ai_project_client(self, mock_azure_credenti
184185
185186 # Assertions
186187 assert result == "Query results data with AI Project Client"
187- mock_client .assert_called_once_with (
188- endpoint = "https://test-openai.azure.com/" ,
189- credential = mock_azure_credential ,
188+ mock_ai_project_client .assert_called_once_with (
189+ endpoint = chat_plugin . ai_project_endpoint ,
190+ credential = mock_credential_instance
190191 )
191192 mock_execute_sql .assert_called_once_with ("\n SELECT * FROM km_processed_data\n " )
192193
0 commit comments