Test whole remote backups through a fake ssh command

Real rsync runs over fake ssh and sshpass scripts that execute the remote side locally, covering --link-dest, removal, key file, password and --remote-sudo without a server.
This commit is contained in:
Fuxino
2026-10-21 22:48:35 +02:00
parent 34e3e41382
commit 4ac8b64085
3 changed files with 130 additions and 22 deletions
+2 -21
View File
@@ -3,8 +3,7 @@
import errno
import io
import os
from collections.abc import Callable, Iterator
from datetime import datetime, timedelta
from collections.abc import Callable
from pathlib import Path
from shutil import which
from typing import Any
@@ -16,25 +15,7 @@ from simple_backup import simple_backup as sb
OPTIONS = '-r -v --ignore-missing-args --mkpath -a -h -H -X -s'
@pytest.fixture(autouse=True)
def fake_now(monkeypatch: pytest.MonkeyPatch) -> None:
"""Give each backup a new timestamp, as real runs within the same second would collide"""
def times() -> Iterator[datetime]:
t = datetime(2026, 10, 14, 10, 0, 0)
while True:
yield t
t += timedelta(hours=1)
it = times()
class FakeDatetime:
@staticmethod
def now() -> datetime:
return next(it)
monkeypatch.setattr(sb, 'datetime', FakeDatetime)
pytestmark = pytest.mark.usefixtures('fake_now')
@pytest.fixture