mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 23:05:00 +00:00
feat: add tests for find_filename
This commit is contained in:
parent
510e50cbe6
commit
528a3372d8
1 changed files with 32 additions and 0 deletions
|
@ -16,6 +16,38 @@ class TestUtils(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.GPT35 = Model("gpt-3.5-turbo")
|
self.GPT35 = Model("gpt-3.5-turbo")
|
||||||
|
|
||||||
|
def test_find_filename(self):
|
||||||
|
fence = ("```", "```")
|
||||||
|
valid_fnames = ["file1.py", "file2.py", "dir/file3.py"]
|
||||||
|
|
||||||
|
# Test with filename on a single line
|
||||||
|
lines = ["file1.py", "```"]
|
||||||
|
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "file1.py")
|
||||||
|
|
||||||
|
# Test with filename and fence on separate lines
|
||||||
|
lines = ["file2.py", "```", "some content"]
|
||||||
|
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "file2.py")
|
||||||
|
|
||||||
|
# Test with filename in fence
|
||||||
|
lines = ["```python", "file3.py", "```"]
|
||||||
|
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "dir/file3.py")
|
||||||
|
|
||||||
|
# Test with no valid filename
|
||||||
|
lines = ["```", "invalid_file.py", "```"]
|
||||||
|
self.assertIsNone(eb.find_filename(lines, fence, valid_fnames))
|
||||||
|
|
||||||
|
# Test with multiple fences
|
||||||
|
lines = ["```python", "file1.py", "```", "```", "file2.py", "```"]
|
||||||
|
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "file2.py")
|
||||||
|
|
||||||
|
# Test with filename having extra characters
|
||||||
|
lines = ["# file1.py", "```"]
|
||||||
|
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "file1.py")
|
||||||
|
|
||||||
|
# Test with fuzzy matching
|
||||||
|
lines = ["file1_py", "```"]
|
||||||
|
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "file1.py")
|
||||||
|
|
||||||
# fuzzy logic disabled v0.11.2-dev
|
# fuzzy logic disabled v0.11.2-dev
|
||||||
def __test_replace_most_similar_chunk(self):
|
def __test_replace_most_similar_chunk(self):
|
||||||
whole = "This is a sample text.\nAnother line of text.\nYet another line.\n"
|
whole = "This is a sample text.\nAnother line of text.\nYet another line.\n"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue