From b428cb4c5daed89e8e0ed301da79d01e2a751186 Mon Sep 17 00:00:00 2001 From: Yiorgis Gozadinos Date: Fri, 1 Aug 2025 16:41:24 +0200 Subject: [PATCH] Forgotten test for FileReader --- tests/test_reader.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/test_reader.py diff --git a/tests/test_reader.py b/tests/test_reader.py new file mode 100644 index 00000000..8b7803dc --- /dev/null +++ b/tests/test_reader.py @@ -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