Release SyncVito 1.0.9
This commit is contained in:
1 parent
bb5bfda4fe
commit
4efc1efa18
8 files changed
+136
-9
No files matched your search
@@ -73,3 +73,23 @@ def test_retry_queues_all_ready_tasks(coordinator: SyncCoordinator, monkeypatch:
|
||||
monkeypatch.setattr(coordinator, "enqueue", queued.append)
|
||||
coordinator._check_retries()
|
||||
assert queued == ["first", "second"]
|
||||
|
||||
|
||||
def test_start_resets_stale_progress_before_worker_starts(
|
||||
coordinator: SyncCoordinator, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
from types import SimpleNamespace
|
||||
|
||||
messages = []
|
||||
workers = []
|
||||
coordinator.progress_changed.connect(lambda *entry: messages.append(entry))
|
||||
|
||||
def start(worker) -> None:
|
||||
assert messages and messages[-1][0] == 0
|
||||
assert "AppData" in messages[-1][1]
|
||||
workers.append(worker)
|
||||
|
||||
monkeypatch.setattr(coordinator, "pool", SimpleNamespace(start=start))
|
||||
coordinator.enqueue(coordinator.config.tasks[0].id)
|
||||
assert len(workers) == 1
|
||||
assert coordinator.current_overall_status() == ("active", "Synchronisierung läuft")
|
||||
@@ -20,7 +20,7 @@ def test_waiting_lock_has_priority_over_active_task() -> None:
|
||||
def test_waiting_task_does_not_hide_running_sync() -> None:
|
||||
assert derive_overall_status([TaskRuntimeState.WAITING_FOR_RELEASE], False, running=True) == (
|
||||
"error",
|
||||
"Synchronisiert",
|
||||
"Synchronisierung läuft",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,72 @@ def _engine(tmp_path: Path) -> SyncEngine:
|
||||
return SyncEngine(StateStore(tmp_path / "state.json"))
|
||||
|
||||
|
||||
def test_progress_reports_scan_before_copying(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
from itertools import count
|
||||
|
||||
source = tmp_path / "source"
|
||||
target = tmp_path / "target"
|
||||
source.mkdir()
|
||||
(source / "datei.txt").write_text("Inhalt")
|
||||
ticks = count()
|
||||
monkeypatch.setattr("syncvito.sync_engine.monotonic", lambda: float(next(ticks)))
|
||||
messages = []
|
||||
|
||||
def progress(value: int, detail: str) -> None:
|
||||
messages.append((value, detail))
|
||||
if "eingelesen" in detail or "Dateien gefunden" in detail:
|
||||
assert value == 0
|
||||
assert not (target / "datei.txt").exists()
|
||||
|
||||
result = _engine(tmp_path).synchronize(SyncTask(name="Test", source=str(source), target=str(target)), progress)
|
||||
|
||||
assert result.successful
|
||||
assert "Ordner werden geprüft" in messages[0][1]
|
||||
assert any("Quelle wird eingelesen" in detail for _, detail in messages)
|
||||
assert any("Ziel wird eingelesen" in detail for _, detail in messages)
|
||||
assert any("1 Dateien gefunden" in detail for _, detail in messages)
|
||||
assert messages[-1][0] == 100
|
||||
|
||||
|
||||
@pytest.mark.skipif(os.name != "nt", reason="Windows-Junctions")
|
||||
def test_inventory_does_not_follow_windows_junctions(tmp_path: Path) -> None:
|
||||
import _winapi
|
||||
|
||||
source = tmp_path / "source"
|
||||
outside = tmp_path / "outside"
|
||||
source.mkdir()
|
||||
outside.mkdir()
|
||||
(outside / "extern.txt").write_text("Nicht synchronisieren")
|
||||
(source / "lokal.txt").write_text("Synchronisieren")
|
||||
junction = source / "verknuepfung"
|
||||
_winapi.CreateJunction(str(outside), str(junction))
|
||||
try:
|
||||
files, directories = SyncEngine._inventory(source, [])
|
||||
assert set(files) == {"lokal.txt"}
|
||||
assert "verknuepfung" not in directories
|
||||
finally:
|
||||
junction.rmdir()
|
||||
|
||||
|
||||
def test_inventory_prunes_unselected_subtrees(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
source = tmp_path / "source"
|
||||
(source / "auswahl").mkdir(parents=True)
|
||||
(source / "ignorieren" / "unterordner").mkdir(parents=True)
|
||||
(source / "auswahl" / "ja.txt").write_text("ja")
|
||||
visited = []
|
||||
original_walk = os.walk
|
||||
|
||||
def walk(*args, **kwargs):
|
||||
for entry in original_walk(*args, **kwargs):
|
||||
visited.append(Path(entry[0]))
|
||||
yield entry
|
||||
|
||||
monkeypatch.setattr("syncvito.sync_engine.os.walk", walk)
|
||||
files, _ = SyncEngine._inventory(source, ["auswahl"])
|
||||
assert set(files) == {str(Path("auswahl/ja.txt"))}
|
||||
assert visited == [source, source / "auswahl"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("winerror", [None, 5])
|
||||
def test_access_denied_is_not_reported_as_file_lock(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, winerror: int | None
|
||||
|
||||
Reference in new issue
Block a user