@@ -57,6 +57,34 @@ def test_validation_errors(self) -> None:
5757 result = tool .execute (json_string )
5858 assert result ["message" ] == "Success"
5959
60+ def test_multiple_account_ids_validation (self ) -> None :
61+ """Test validation with multiple account IDs."""
62+ tool = create_feedback_tool (api_key = "test_key" )
63+
64+ # Test empty account ID list
65+ with pytest .raises (StackOneError , match = "At least one account ID is required" ):
66+ tool .execute ({"feedback" : "Great tools!" , "account_id" : [], "tool_names" : ["test_tool" ]})
67+
68+ # Test account ID list with empty strings
69+ with pytest .raises (StackOneError , match = "At least one valid account ID is required" ):
70+ tool .execute ({"feedback" : "Great tools!" , "account_id" : ["" , " " ], "tool_names" : ["test_tool" ]})
71+
72+ # Test valid multiple account IDs
73+ with patch ("requests.request" ) as mock_request :
74+ mock_response = Mock ()
75+ mock_response .status_code = 200
76+ mock_response .json .return_value = {"message" : "Success" }
77+ mock_response .raise_for_status = Mock ()
78+ mock_request .return_value = mock_response
79+
80+ result = tool .execute ({
81+ "feedback" : "Great tools!" ,
82+ "account_id" : ["acc_123456" , "acc_789012" ],
83+ "tool_names" : ["test_tool" ]
84+ })
85+ assert "total_accounts" in result
86+ assert result ["total_accounts" ] == 2
87+
6088
6189class TestFeedbackToolExecution :
6290 """Test suite for feedback tool execution."""
@@ -151,6 +179,94 @@ def test_handles_api_errors(self) -> None:
151179 }
152180 )
153181
182+ def test_multiple_account_ids_execution (self ) -> None :
183+ """Test execution with multiple account IDs."""
184+ tool = create_feedback_tool (api_key = "test_key" )
185+
186+ api_response = {
187+ "message" : "Feedback successfully stored" ,
188+ "key" : "test-key.json" ,
189+ "submitted_at" : "2025-10-08T11:44:16.123Z" ,
190+ "trace_id" : "test-trace-id" ,
191+ }
192+
193+ with patch ("requests.request" ) as mock_request :
194+ mock_response = Mock ()
195+ mock_response .status_code = 200
196+ mock_response .json .return_value = api_response
197+ mock_response .raise_for_status = Mock ()
198+ mock_request .return_value = mock_response
199+
200+ result = tool .execute ({
201+ "feedback" : "Great tools!" ,
202+ "account_id" : ["acc_123456" , "acc_789012" , "acc_345678" ],
203+ "tool_names" : ["test_tool" ]
204+ })
205+
206+ # Check combined result structure
207+ assert result ["message" ] == "Feedback sent to 3 account(s)"
208+ assert result ["total_accounts" ] == 3
209+ assert result ["successful" ] == 3
210+ assert result ["failed" ] == 0
211+ assert len (result ["results" ]) == 3
212+
213+ # Check individual results
214+ for i , account_id in enumerate (["acc_123456" , "acc_789012" , "acc_345678" ]):
215+ assert result ["results" ][i ]["account_id" ] == account_id
216+ assert result ["results" ][i ]["status" ] == "success"
217+ assert result ["results" ][i ]["result" ] == api_response
218+
219+ # Verify API was called 3 times
220+ assert mock_request .call_count == 3
221+
222+ def test_multiple_account_ids_with_errors (self ) -> None :
223+ """Test execution with multiple account IDs where some fail."""
224+ tool = create_feedback_tool (api_key = "test_key" )
225+
226+ success_response = {"message" : "Success" }
227+
228+ def mock_request_side_effect (* args , ** kwargs ):
229+ account_id = kwargs .get ("json" , {}).get ("account_id" )
230+ if account_id == "acc_123456" :
231+ # Success case
232+ mock_response = Mock ()
233+ mock_response .status_code = 200
234+ mock_response .json .return_value = success_response
235+ mock_response .raise_for_status = Mock ()
236+ return mock_response
237+ else :
238+ # Error case
239+ mock_response = Mock ()
240+ mock_response .status_code = 401
241+ mock_response .text = '{"error": "Unauthorized"}'
242+ mock_response .json .return_value = {"error" : "Unauthorized" }
243+ mock_response .raise_for_status .side_effect = Exception ("401 Client Error: Unauthorized" )
244+ return mock_response
245+
246+ with patch ("requests.request" ) as mock_request :
247+ mock_request .side_effect = mock_request_side_effect
248+
249+ result = tool .execute ({
250+ "feedback" : "Great tools!" ,
251+ "account_id" : ["acc_123456" , "acc_unauthorized" ],
252+ "tool_names" : ["test_tool" ]
253+ })
254+
255+ # Check combined result structure
256+ assert result ["total_accounts" ] == 2
257+ assert result ["successful" ] == 1
258+ assert result ["failed" ] == 1
259+ assert len (result ["results" ]) == 2
260+
261+ # Check individual results
262+ success_result = next (r for r in result ["results" ] if r ["account_id" ] == "acc_123456" )
263+ assert success_result ["status" ] == "success"
264+ assert success_result ["result" ] == success_response
265+
266+ error_result = next (r for r in result ["results" ] if r ["account_id" ] == "acc_unauthorized" )
267+ assert error_result ["status" ] == "error"
268+ assert "401 Client Error: Unauthorized" in error_result ["error" ]
269+
154270
155271class TestFeedbackToolIntegration :
156272 """Test suite for feedback tool integration."""
0 commit comments