Skip to content

Commit a2dd876

Browse files
committed
refactor: remove unused imports and obsolete skipped tests - cleanup test suite
Signed-off-by: Roberto Rodriguez <[email protected]>
1 parent 9f7125e commit a2dd876

File tree

7 files changed

+262
-330
lines changed

7 files changed

+262
-330
lines changed

tests/agents/agent/test_agent.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def test_agent_initialization(self, mock_llm):
8282
assert agent.prompting_helper.instructions == ["Be helpful"]
8383
assert agent.execution_config.max_iterations == 10 # default value
8484
assert agent.tool_history == []
85-
assert agent.execution_config.tool_choice == "auto" # auto when tools are provided
85+
assert (
86+
agent.execution_config.tool_choice == "auto"
87+
) # auto when tools are provided
8688

8789
def test_agent_initialization_without_tools(self, mock_llm):
8890
"""Test agent initialization without tools."""
@@ -141,7 +143,9 @@ async def test_run_agent_basic(self, basic_agent):
141143
mock_response.get_message.return_value = assistant_msg
142144
basic_agent.llm.generate.return_value = mock_response
143145

144-
result = await basic_agent._run_agent(input_data="Hello", instance_id="test-123")
146+
result = await basic_agent._run_agent(
147+
input_data="Hello", instance_id="test-123"
148+
)
145149

146150
assert isinstance(result, AssistantMessage)
147151
assert result.content == "Hello!"
@@ -172,7 +176,9 @@ async def test_run_agent_with_tool_calls(self, agent_with_tools):
172176
tools=[echo_tool]
173177
)
174178

175-
result = await agent_with_tools._run_agent(input_data="Use the tool", instance_id="test-123")
179+
result = await agent_with_tools._run_agent(
180+
input_data="Use the tool", instance_id="test-123"
181+
)
176182
assert isinstance(result, AssistantMessage)
177183
assert result.content == "Final answer"
178184

@@ -189,16 +195,18 @@ async def test_process_response_success(self, agent_with_tools):
189195
agent_with_tools.tool_executor = agent_with_tools.tool_executor.__class__(
190196
tools=[echo_tool]
191197
)
192-
198+
193199
# Call the actual internal method that executes tool calls
194-
tool_messages = await agent_with_tools._execute_tool_calls("test-instance", [tool_call])
195-
200+
tool_messages = await agent_with_tools._execute_tool_calls(
201+
"test-instance", [tool_call]
202+
)
203+
196204
assert len(agent_with_tools.tool_history) == 1
197205
tool_record = agent_with_tools.tool_history[0]
198206
assert tool_record.tool_call_id == "call_123"
199207
assert tool_record.tool_name == echo_tool.name
200208
assert tool_record.execution_result == "value1"
201-
209+
202210
# Verify the tool message was returned
203211
assert len(tool_messages) == 1
204212
assert tool_messages[0]["role"] == "tool"
@@ -216,7 +224,7 @@ async def test_process_response_failure(self, agent_with_tools):
216224
agent_with_tools.tool_executor = agent_with_tools.tool_executor.__class__(
217225
tools=[error_tool]
218226
)
219-
227+
220228
# Call the actual internal method that executes tool calls
221229
with pytest.raises(
222230
AgentError, match=f"Error executing tool '{error_tool.name}': .*Tool failed"
@@ -233,8 +241,7 @@ async def test_conversation_max_reached(self, basic_agent):
233241
# Call the actual internal conversation loop method
234242
initial_messages = [{"role": "user", "content": "Hello"}]
235243
result = await basic_agent._conversation_loop(
236-
instance_id="test-123",
237-
messages=initial_messages
244+
instance_id="test-123", messages=initial_messages
238245
)
239246

240247
# current logic sees no tools ===> returns on first iteration
@@ -252,8 +259,7 @@ async def test_conversation_with_llm_error(self, basic_agent):
252259
AgentError, match="Failed during chat generation: LLM error"
253260
):
254261
await basic_agent._conversation_loop(
255-
instance_id="test-123",
256-
messages=initial_messages
262+
instance_id="test-123", messages=initial_messages
257263
)
258264

259265
async def test_run_tool_success(self, agent_with_tools):
@@ -262,18 +268,18 @@ async def test_run_tool_success(self, agent_with_tools):
262268
agent_with_tools.tool_executor = agent_with_tools.tool_executor.__class__(
263269
tools=[echo_tool]
264270
)
265-
271+
266272
# Create a mock tool call
267273
mock_function = Mock()
268274
mock_function.name = echo_tool.name
269275
mock_function.arguments_dict = {"arg1": "value1"}
270276
tool_call = Mock(spec=ToolCall)
271277
tool_call.id = "call_123"
272278
tool_call.function = mock_function
273-
279+
274280
# Call the actual internal method
275281
result = await agent_with_tools._run_tool_call("test-instance", tool_call)
276-
282+
277283
# Verify the result is a tool message dict
278284
assert result["role"] == "tool"
279285
assert result["name"] == echo_tool.name
@@ -285,15 +291,15 @@ async def test_run_tool_failure(self, agent_with_tools):
285291
agent_with_tools.tool_executor = agent_with_tools.tool_executor.__class__(
286292
tools=[error_tool]
287293
)
288-
294+
289295
# Create a mock tool call
290296
mock_function = Mock()
291297
mock_function.name = error_tool.name
292298
mock_function.arguments_dict = {}
293299
tool_call = Mock(spec=ToolCall)
294300
tool_call.id = "call_123"
295301
tool_call.function = mock_function
296-
302+
297303
# Call the actual internal method
298304
with pytest.raises(
299305
AgentError, match=f"Error executing tool '{error_tool.name}': .*Tool failed"

0 commit comments

Comments
 (0)