Skip to content

Commit f6354b9

Browse files
committed
feat(test_text_editor.py): add test for reading multiple ranges from a file to ensure correct content retrieval and handling of unspecified end ranges
1 parent 220abf9 commit f6354b9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_text_editor.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,33 @@ async def test_edit_file_contents_with_preserving_newlines(editor, tmp_path):
280280
expected_content = "line1\nnew line2\nline3\n"
281281
final_content = test_file.read_text()
282282
assert final_content == expected_content
283+
284+
285+
@pytest.mark.asyncio
286+
async def test_read_multiple_ranges(editor, test_file):
287+
"""Test reading multiple ranges including ranges with no end specified."""
288+
ranges = [
289+
{
290+
"file_path": test_file,
291+
"ranges": [
292+
{"start": 1}, # Read from start to end (no end specified)
293+
{"start": 2, "end": 4}, # Read specific range
294+
],
295+
}
296+
]
297+
298+
result = await editor.read_multiple_ranges(ranges)
299+
300+
# Check first range (entire file)
301+
first_range = result[test_file][0]
302+
assert first_range["content"] == "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\n"
303+
assert first_range["start_line"] == 1
304+
assert first_range["end_line"] == 5
305+
assert first_range["total_lines"] == 5
306+
307+
# Check second range (specific lines)
308+
second_range = result[test_file][1]
309+
assert second_range["content"] == "Line 2\nLine 3\nLine 4\n"
310+
assert second_range["start_line"] == 2
311+
assert second_range["end_line"] == 4
312+
assert second_range["total_lines"] == 5

0 commit comments

Comments
 (0)