Release SyncVito 1.0.10
This commit is contained in:
1 parent
4efc1efa18
commit
7098fa1c0c
9 files changed
+317
-20
No files matched your search
@@ -93,3 +93,47 @@ def test_start_resets_stale_progress_before_worker_starts(
|
||||
coordinator.enqueue(coordinator.config.tasks[0].id)
|
||||
assert len(workers) == 1
|
||||
assert coordinator.current_overall_status() == ("active", "Synchronisierung läuft")
|
||||
|
||||
|
||||
def test_pause_and_resume_preserves_queue_and_state(coordinator: SyncCoordinator) -> None:
|
||||
task1 = coordinator.config.tasks[0]
|
||||
task2 = SyncTask(name="Documents", source="c:/src2", target="c:/dst2")
|
||||
coordinator.config.tasks.append(task2)
|
||||
|
||||
# Global pausieren
|
||||
coordinator.set_paused(True)
|
||||
assert coordinator.config.settings.paused
|
||||
assert coordinator.current_overall_status() == ("paused", "Pausiert")
|
||||
|
||||
# Aufgaben in Warteschlange einreihen
|
||||
coordinator.enqueue(task1.id)
|
||||
coordinator.enqueue(task2.id)
|
||||
|
||||
assert coordinator.queued_task_ids == [task1.id, task2.id]
|
||||
assert coordinator.config.settings.pending_queue == [task1.id, task2.id]
|
||||
|
||||
# Fortsetzen
|
||||
workers = []
|
||||
from types import SimpleNamespace
|
||||
|
||||
coordinator.pool = SimpleNamespace(start=workers.append)
|
||||
coordinator.set_paused(False)
|
||||
|
||||
assert not coordinator.config.settings.paused
|
||||
assert len(workers) == 1
|
||||
assert coordinator.running_task_id == task1.id
|
||||
assert coordinator.queued_task_ids == [task2.id]
|
||||
|
||||
|
||||
def test_stop_persists_running_task_and_queue_for_restart(coordinator: SyncCoordinator) -> None:
|
||||
task1 = coordinator.config.tasks[0]
|
||||
task2 = SyncTask(name="Documents", source="c:/src2", target="c:/dst2")
|
||||
coordinator.config.tasks.append(task2)
|
||||
|
||||
coordinator._running_task_id = task1.id
|
||||
coordinator._queue.append(task2.id)
|
||||
|
||||
coordinator.stop()
|
||||
|
||||
assert coordinator.config.settings.paused is True
|
||||
assert coordinator.config.settings.pending_queue == [task1.id, task2.id]
|
||||
@@ -223,3 +223,49 @@ def test_bidirectional_mirrors_known_deletion(tmp_path: Path) -> None:
|
||||
|
||||
assert result.successful
|
||||
assert not (source / "entfernen.txt").exists()
|
||||
|
||||
|
||||
def test_stage_progress_reporting_for_multiple_folders(tmp_path: Path) -> None:
|
||||
source = tmp_path / "source"
|
||||
target = tmp_path / "target"
|
||||
(source / "AppData").mkdir(parents=True)
|
||||
(source / "Documents").mkdir(parents=True)
|
||||
(source / "AppData" / "config.json").write_text("{}", encoding="utf-8")
|
||||
(source / "Documents" / "doc.txt").write_text("text", encoding="utf-8")
|
||||
task = SyncTask(name="Backup", source=str(source), target=str(target))
|
||||
|
||||
messages: list[tuple[int, str]] = []
|
||||
result = _engine(tmp_path).synchronize(task, progress=lambda v, d: messages.append((v, d)))
|
||||
|
||||
assert result.successful
|
||||
assert any("[1/2 AppData]" in detail for _, detail in messages)
|
||||
assert any("[2/2 Documents]" in detail for _, detail in messages)
|
||||
|
||||
|
||||
def test_pause_and_resume_continues_where_interrupted(tmp_path: Path) -> None:
|
||||
source = tmp_path / "source"
|
||||
target = tmp_path / "target"
|
||||
source.mkdir()
|
||||
(source / "a.txt").write_text("a", encoding="utf-8")
|
||||
(source / "b.txt").write_text("b", encoding="utf-8")
|
||||
(source / "c.txt").write_text("c", encoding="utf-8")
|
||||
task = SyncTask(name="ResumeTest", source=str(source), target=str(target))
|
||||
engine = _engine(tmp_path)
|
||||
|
||||
# 1. Unterbrechung nach der ersten Datei
|
||||
def cancel_after_one() -> bool:
|
||||
return (target / "a.txt").exists()
|
||||
|
||||
result_paused = engine.synchronize(task, cancel_check=cancel_after_one)
|
||||
assert result_paused.paused
|
||||
assert not result_paused.successful
|
||||
assert (target / "a.txt").exists()
|
||||
assert not (target / "c.txt").exists()
|
||||
|
||||
# 2. Fortsetzen: Bereits kopierte Datei a.txt wird übersprungen, b und c werden kopiert
|
||||
result_resumed = engine.synchronize(task)
|
||||
assert result_resumed.successful
|
||||
assert result_resumed.copied == 2
|
||||
assert (target / "a.txt").exists()
|
||||
assert (target / "b.txt").exists()
|
||||
assert (target / "c.txt").exists()
|
||||
Reference in new issue
Block a user