Added a new test that does not mock the retriever.

This commit is contained in:
Paul Gauthier (aider) 2024-07-05 17:33:43 -03:00
parent a8af4a3109
commit 51c13c549c

View file

@ -12,7 +12,7 @@ class TestHelp(unittest.TestCase):
def test_init(self): def test_init(self):
self.assertIsNotNone(self.help.retriever) self.assertIsNotNone(self.help.retriever)
def test_ask(self): def test_ask_with_mock(self):
mock_node = MagicMock() mock_node = MagicMock()
mock_node.text = "Test content" mock_node.text = "Test content"
mock_node.metadata = {"url": "https://example.com"} mock_node.metadata = {"url": "https://example.com"}
@ -25,6 +25,20 @@ class TestHelp(unittest.TestCase):
self.assertIn("Test content", result) self.assertIn("Test content", result)
self.assertIn("</doc>", result) self.assertIn("</doc>", result)
def test_ask_without_mock(self):
help_instance = Help()
question = "What is aider?"
result = help_instance.ask(question)
self.assertIn(f"# Question: {question}", result)
self.assertIn("<doc", result)
self.assertIn("</doc>", result)
self.assertGreater(len(result), 100) # Ensure we got a substantial response
# Check for some expected content (adjust based on your actual help content)
self.assertIn("aider", result.lower())
self.assertIn("ai", result.lower())
self.assertIn("chat", result.lower())
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()