mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 18:25:00 +00:00
Removed unnecessary mocking and simplified the TestHelp
class.
This commit is contained in:
parent
51c13c549c
commit
d21d8da374
1 changed files with 2 additions and 17 deletions
|
@ -3,28 +3,13 @@ from unittest.mock import patch, MagicMock
|
||||||
from aider.help import Help
|
from aider.help import Help
|
||||||
|
|
||||||
class TestHelp(unittest.TestCase):
|
class TestHelp(unittest.TestCase):
|
||||||
@patch('aider.help.get_index')
|
|
||||||
def setUp(self, mock_get_index):
|
def setUp(self):
|
||||||
self.mock_index = MagicMock()
|
|
||||||
mock_get_index.return_value = self.mock_index
|
|
||||||
self.help = Help()
|
self.help = Help()
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
self.assertIsNotNone(self.help.retriever)
|
self.assertIsNotNone(self.help.retriever)
|
||||||
|
|
||||||
def test_ask_with_mock(self):
|
|
||||||
mock_node = MagicMock()
|
|
||||||
mock_node.text = "Test content"
|
|
||||||
mock_node.metadata = {"url": "https://example.com"}
|
|
||||||
self.help.retriever.retrieve.return_value = [mock_node]
|
|
||||||
|
|
||||||
result = self.help.ask("Test question")
|
|
||||||
|
|
||||||
self.assertIn("# Question: Test question", result)
|
|
||||||
self.assertIn('<doc from_url="https://example.com">', result)
|
|
||||||
self.assertIn("Test content", result)
|
|
||||||
self.assertIn("</doc>", result)
|
|
||||||
|
|
||||||
def test_ask_without_mock(self):
|
def test_ask_without_mock(self):
|
||||||
help_instance = Help()
|
help_instance = Help()
|
||||||
question = "What is aider?"
|
question = "What is aider?"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue