{
"event": "PreToolUse",
"tool_name": "Write",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/crawler\/tests\/integration\/infrastructure\/test_file_storage.py",
"content": "from __future__ import annotations\n\nimport gzip\nimport pathlib\n\nimport pytest\n\nfrom src.infrastructure.storage.file_storage import LocalFileStorage\n\n\n@pytest.fixture\ndef storage(tmp_path: pathlib.Path) -> LocalFileStorage:\n return LocalFileStorage(\n html_root=tmp_path \/ \"html\",\n screenshot_root=tmp_path \/ \"screenshots\",\n )\n\n\ndef test_store_html_gzip_roundtrip(storage: LocalFileStorage) -> None:\n url_hash = \"a\" * 64\n path = pathlib.Path(storage.store_html(1, url_hash, b\"<html>hello<\/html>\"))\n assert path.exists()\n assert gzip.decompress(path.read_bytes()) == b\"<html>hello<\/html>\"\n\n\ndef test_store_screenshot_writes_png(storage: LocalFileStorage) -> None:\n url_hash = \"b\" * 64\n path = pathlib.Path(storage.store_screenshot(2, url_hash, b\"\\x89PNG\"))\n assert path.exists()\n assert path.read_bytes() == b\"\\x89PNG\"\n\n\ndef test_invalid_hash_rejected(storage: LocalFileStorage) -> None:\n with pytest.raises(ValueError, match=\"url_hash\"):\n storage.store_html(1, \"short\", b\"x\")\n"
}
}
{
"tool_response": {
"type": "create",
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/crawler\/tests\/integration\/infrastructure\/test_file_storage.py",
"content": "from __future__ import annotations\n\nimport gzip\nimport pathlib\n\nimport pytest\n\nfrom src.infrastructure.storage.file_storage import LocalFileStorage\n\n\n@pytest.fixture\ndef storage(tmp_path: pathlib.Path) -> LocalFileStorage:\n return LocalFileStorage(\n html_root=tmp_path \/ \"html\",\n screenshot_root=tmp_path \/ \"screenshots\",\n )\n\n\ndef test_store_html_gzip_roundtrip(storage: LocalFileStorage) -> None:\n url_hash = \"a\" * 64\n path = pathlib.Path(storage.store_html(1, url_hash, b\"<html>hello<\/html>\"))\n assert path.exists()\n assert gzip.decompress(path.read_bytes()) == b\"<html>hello<\/html>\"\n\n\ndef test_store_screenshot_writes_png(storage: LocalFileStorage) -> None:\n url_hash = \"b\" * 64\n path = pathlib.Path(storage.store_screenshot(2, url_hash, b\"\\x89PNG\"))\n assert path.exists()\n assert path.read_bytes() == b\"\\x89PNG\"\n\n\ndef test_invalid_hash_rejected(storage: LocalFileStorage) -> None:\n with pytest.raises(ValueError, match=\"url_hash\"):\n storage.store_html(1, \"short\", b\"x\")\n",
"structuredPatch": [],
"originalFile": null,
"userModified": false
}
}