Forgotten test for FileReader
This commit is contained in:
parent
a453853211
commit
b428cb4c5d
1 changed files with 22 additions and 0 deletions
22
tests/test_reader.py
Normal file
22
tests/test_reader.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from haiku.rag.reader import FileReader
|
||||
|
||||
|
||||
def test_code_file_wrapped_in_code_block():
|
||||
"""Test that code files are wrapped in markdown code blocks."""
|
||||
python_code = '''def hello_world():
|
||||
print("Hello, World!")
|
||||
return "success"'''
|
||||
|
||||
with tempfile.NamedTemporaryFile(mode="w", suffix=".py") as f:
|
||||
f.write(python_code)
|
||||
f.flush()
|
||||
temp_path = Path(f.name)
|
||||
|
||||
result = FileReader.parse_file(temp_path)
|
||||
|
||||
assert result.startswith("```python\n")
|
||||
assert result.endswith("\n```")
|
||||
assert "def hello_world():" in result
|
||||
Loading…
Reference in a new issue