From 1df9b1b166f76a3cd282a247bc234bed52706d1e Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 21 Jun 2025 21:01:12 +0000 Subject: [PATCH] Add negative test cases and improve test coverage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add test for malformed template handling - Add test for missing required parameters with proper error handling - Improve test documentation and edge case coverage Addresses GitHub review feedback from joaomdmoura and mplachta Co-Authored-By: João --- tests/test_prompt_customization_docs.py | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/test_prompt_customization_docs.py b/tests/test_prompt_customization_docs.py index a9b95d6e2..bc61d3376 100644 --- a/tests/test_prompt_customization_docs.py +++ b/tests/test_prompt_customization_docs.py @@ -460,3 +460,47 @@ DISCLAIMER: This analysis is for informational purposes only.""" assert lite_agent_with_tools.role == "Reviewer" assert len(lite_agent_with_tools.tools) == 1 assert lite_agent_with_tools.tools[0].name == "mock_tool" + + def test_malformed_template_handling(self): + """Test handling of malformed or incomplete templates gracefully. + + Validates: + - Agent creation succeeds with malformed templates + - Missing placeholders don't cause failures + - System handles edge cases gracefully + """ + incomplete_template = "This is a template without placeholders" + + agent = Agent( + role="Test Agent", + goal="Test incomplete templates", + backstory="Agent for testing edge cases.", + system_template=incomplete_template, + llm="gpt-4o-mini" + ) + + assert agent.system_template == incomplete_template + assert agent.role == "Test Agent" + + agent_empty = Agent( + role="Empty Template Agent", + goal="Test empty templates", + backstory="Agent with empty template.", + response_template="", + llm="gpt-4o-mini" + ) + + assert agent_empty.response_template == "" + + def test_agent_creation_with_missing_required_parameters(self): + """Test agent creation behavior when required parameters are missing. + + Validates: + - Agent creation requires role, goal, and backstory + - Appropriate errors are raised for missing parameters + """ + with pytest.raises((TypeError, ValueError)): + Agent(llm="gpt-4o-mini") # Missing required parameters + + with pytest.raises((TypeError, ValueError)): + Agent(role="Test", llm="gpt-4o-mini") # Missing goal and backstory