Prepare isolated offsite restore and stream large backup transfers
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a06ecb-456a-71c2-b41e-0755d336e883
This commit is contained in:
parent
d0c7249a0d
commit
0cca68da96
4 changed files with 217 additions and 15 deletions
21
tests/test_offsite_restore_boundaries.py
Normal file
21
tests/test_offsite_restore_boundaries.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import importlib.util
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
import sys
|
||||
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'scripts'))
|
||||
import verify_nextcloud_offsite_restore as transfer
|
||||
import restore_forgejo_offsite_locally as restore
|
||||
|
||||
class RestoreBoundary(unittest.TestCase):
|
||||
def test_missing_backup_never_fetches_credentials(self):
|
||||
with tempfile.TemporaryDirectory() as d, patch.object(transfer,'bao') as bao:
|
||||
with self.assertRaises(transfer.LaneError): transfer.run(Path(d)/'absent.zip.age',Path(d)/'stage',{})
|
||||
bao.assert_not_called()
|
||||
|
||||
def test_truncated_backup_never_starts_docker(self):
|
||||
with tempfile.TemporaryDirectory() as d, patch.object(restore.subprocess,'run') as command:
|
||||
p=Path(d)/'fetched.zip';p.write_bytes(b'PK\x03\x04truncated')
|
||||
with self.assertRaises(Exception): restore.run(p,{})
|
||||
command.assert_not_called()
|
||||
Loading…
Add table
Add a link
Reference in a new issue