@@ -89,16 +89,30 @@ async def test_update_pipeline_yaml_success_json_response() -> None:
8989 assert result == {"status" : "success" , "message" : "Updated" }
9090
9191
92+ @pytest .mark .asyncio
9293@mock .patch .dict (os .environ , {"DEEPSET_WORKSPACE" : TEST_WORKSPACE , "DEEPSET_API_KEY" : TEST_API_KEY })
93- @mock .patch ("deepset_mcp.client.DeepsetClient.update_pipeline_yaml" )
94- def test_update_pipeline_yaml_success_empty_response (mock_update : mock .Mock ) -> None :
94+ async def test_update_pipeline_yaml_success_empty_response () -> None :
9595 """Tests successful update with empty response body."""
96- mock_update .return_value = {"status" : "success" , "message" : "Pipeline YAML updated successfully (empty response body)" }
97-
98- result = update_pipeline_yaml (TEST_PIPELINE_NAME , VALID_YAML_CONTENT )
99-
100- mock_update .assert_called_once_with (TEST_PIPELINE_NAME , VALID_YAML_CONTENT )
101- assert result == {"status" : "success" , "message" : "Pipeline YAML updated successfully (empty response body)" }
96+ # Since update_pipeline_yaml is async, we need to test it differently
97+ with mock .patch ("deepset_mcp.main.DeepsetClient" ) as mock_client_class :
98+ # Setup the mock client instance
99+ mock_client_instance = mock .MagicMock ()
100+ mock_client_instance .__aenter__ .return_value = mock_client_instance
101+ mock_client_instance .__aexit__ .return_value = None
102+ mock_client_instance .workspace = TEST_WORKSPACE
103+ mock_client_instance .request .return_value = {"status" : "success" , "message" : "API returned empty response body" }
104+ mock_client_class .return_value = mock_client_instance
105+
106+ # Call the function
107+ result = await update_pipeline_yaml (TEST_PIPELINE_NAME , VALID_YAML_CONTENT )
108+
109+ # Verify the call was made correctly
110+ mock_client_instance .request .assert_called_once_with (
111+ f"/workspaces/{ TEST_WORKSPACE } /pipelines/{ TEST_PIPELINE_NAME } /yaml" ,
112+ method = "PUT" ,
113+ data = {"query_yaml" : VALID_YAML_CONTENT }
114+ )
115+ assert result == {"status" : "success" , "message" : "API returned empty response body" }
102116
103117
104118@mock .patch .dict (os .environ , {"DEEPSET_WORKSPACE" : TEST_WORKSPACE , "DEEPSET_API_KEY" : TEST_API_KEY })
0 commit comments