| 1 | from pathlib import Path |
| 2 | import zipfile |
| 3 | |
| 4 | from api.download_work_dir_file import resolve_download_path |
| 5 | from api.download_work_dir_files import create_selected_zip |
| 6 | |
| 7 | |
| 8 | def test_download_resolvers_match_file_browser_root(tmp_path: Path) -> None: |
| 9 | file_path = tmp_path / "outside-a0.txt" |
| 10 | file_path.write_text("downloadable", encoding="utf-8") |
| 11 | |
| 12 | assert resolve_download_path(str(file_path)) == str(file_path.resolve()) |
| 13 | |
| 14 | archive_path = Path(create_selected_zip([str(file_path)], "/")) |
| 15 | try: |
| 16 | with zipfile.ZipFile(archive_path) as archive: |
| 17 | name = str(file_path).lstrip("/") |
| 18 | assert archive.namelist() == [name] |
| 19 | assert archive.read(name) == b"downloadable" |
| 20 | finally: |
| 21 | archive_path.unlink(missing_ok=True) |