@@ -173,17 +173,33 @@ async def test_update_pipeline_yaml_api_error_500_text() -> None:
173173 assert result == error_response
174174
175175
176+ @pytest .mark .asyncio
176177@mock .patch .dict (os .environ , {"DEEPSET_WORKSPACE" : TEST_WORKSPACE , "DEEPSET_API_KEY" : TEST_API_KEY })
177- @mock .patch ("deepset_mcp.client.DeepsetClient.update_pipeline_yaml" )
178- def test_update_pipeline_yaml_request_exception (mock_update : mock .Mock ) -> None :
178+ async def test_update_pipeline_yaml_request_exception () -> None :
179179 """Tests network request failure."""
180- mock_update .return_value = {"error" : "Request failed: Connection timed out" }
181-
182- result = update_pipeline_yaml (TEST_PIPELINE_NAME , VALID_YAML_CONTENT )
183-
184- mock_update .assert_called_once_with (TEST_PIPELINE_NAME , VALID_YAML_CONTENT )
185- assert "error" in result
186- assert "Request failed: Connection timed out" in result ["error" ]
180+ error_response = {"error" : "Request failed: Connection timed out" }
181+
182+ # Since update_pipeline_yaml is async, we need to test it differently
183+ with mock .patch ("deepset_mcp.main.DeepsetClient" ) as mock_client_class :
184+ # Setup the mock client instance
185+ mock_client_instance = mock .MagicMock ()
186+ mock_client_instance .__aenter__ .return_value = mock_client_instance
187+ mock_client_instance .__aexit__ .return_value = None
188+ mock_client_instance .workspace = TEST_WORKSPACE
189+ mock_client_instance .request .return_value = error_response
190+ mock_client_class .return_value = mock_client_instance
191+
192+ # Call the function
193+ result = await update_pipeline_yaml (TEST_PIPELINE_NAME , VALID_YAML_CONTENT )
194+
195+ # Verify the call was made correctly
196+ mock_client_instance .request .assert_called_once_with (
197+ f"/workspaces/{ TEST_WORKSPACE } /pipelines/{ TEST_PIPELINE_NAME } /yaml" ,
198+ method = "PUT" ,
199+ data = {"query_yaml" : VALID_YAML_CONTENT }
200+ )
201+ assert "error" in result
202+ assert "Request failed: Connection timed out" in result ["error" ]
187203
188204
189205@mock .patch .dict (os .environ , {"DEEPSET_WORKSPACE" : TEST_WORKSPACE , "DEEPSET_API_KEY" : TEST_API_KEY })
0 commit comments