|
3 | 3 | import pytest |
4 | 4 | from mergin.common import DeltaChangeType, CHUNK_SIZE |
5 | 5 | from mergin.models import ProjectDeltaChange, ProjectDeltaItemDiff |
6 | | -from mergin.client_pull import get_download_diff_files, get_download_items |
| 6 | +from mergin.client_pull import DownloadQueueItem, UpdateTask, get_download_diff_files, get_download_items |
7 | 7 |
|
8 | 8 |
|
9 | 9 | def test_get_diff_download_files(): |
@@ -74,3 +74,20 @@ def test_get_download_items(): |
74 | 74 | assert items[0].file_path == "base.gpkg" |
75 | 75 | assert items[0].size == 50 |
76 | 76 | assert items[0].download_file_path == os.path.join(tmp_dir, "diff_file.0") |
| 77 | + |
| 78 | + |
| 79 | +@pytest.mark.parametrize("output_file", ["out.txt", "./out.txt"]) |
| 80 | +def test_update_task_apply_to_bare_filename(output_file, monkeypatch): |
| 81 | + """Single file download must accept an output path without a directory part.""" |
| 82 | + with tempfile.TemporaryDirectory() as tmp_dir: |
| 83 | + chunk_path = os.path.join(tmp_dir, "data.txt.0") |
| 84 | + with open(chunk_path, "wb") as f: |
| 85 | + f.write(b"content") |
| 86 | + item = DownloadQueueItem("data.txt", 7, "v1", False, 0, chunk_path) |
| 87 | + task = UpdateTask("data.txt", [item], destination_file=output_file) |
| 88 | + |
| 89 | + monkeypatch.chdir(tmp_dir) |
| 90 | + task.apply(tmp_dir, None) |
| 91 | + |
| 92 | + with open(os.path.join(tmp_dir, "out.txt"), "rb") as f: |
| 93 | + assert f.read() == b"content" |
0 commit comments