Init
This commit is contained in:
46
tests/test_chunking.py
Normal file
46
tests/test_chunking.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from ai_reviewer.diff import chunk_files, parse_diff
|
||||
|
||||
|
||||
def test_chunking_splits_on_hunks_when_large():
|
||||
diff_text = """
|
||||
diff --git a/app.py b/app.py
|
||||
index 0000000..1111111 100644
|
||||
--- a/app.py
|
||||
+++ b/app.py
|
||||
@@ -1,2 +1,2 @@
|
||||
-print('old')
|
||||
+print('new')
|
||||
@@ -10,2 +10,2 @@
|
||||
-x = 1
|
||||
+x = 2
|
||||
""".strip()
|
||||
|
||||
files = parse_diff(diff_text)
|
||||
chunks = chunk_files(files, max_lines=7)
|
||||
|
||||
assert len(chunks) == 2
|
||||
assert all(chunk.path == "app.py" for chunk in chunks)
|
||||
assert all(len(chunk.hunks) == 1 for chunk in chunks)
|
||||
|
||||
|
||||
def test_chunking_preserves_file_boundaries():
|
||||
diff_text = """
|
||||
diff --git a/a.txt b/a.txt
|
||||
--- a/a.txt
|
||||
+++ b/a.txt
|
||||
@@ -1 +1 @@
|
||||
-a
|
||||
+b
|
||||
diff --git a/b.txt b/b.txt
|
||||
--- a/b.txt
|
||||
+++ b/b.txt
|
||||
@@ -1 +1 @@
|
||||
-c
|
||||
+d
|
||||
""".strip()
|
||||
|
||||
files = parse_diff(diff_text)
|
||||
chunks = chunk_files(files, max_lines=50)
|
||||
|
||||
assert {chunk.path for chunk in chunks} == {"a.txt", "b.txt"}
|
||||
assert all(len(chunk.hunks) == 1 for chunk in chunks)
|
||||
Reference in New Issue
Block a user