Make project docs and integration test generic

This commit is contained in:
Codex
2026-07-15 01:07:22 +02:00
parent 398c1ae6c3
commit ca0269a146
7 changed files with 171 additions and 98 deletions
+12 -12
View File
@@ -12,7 +12,7 @@ def _settings(tmp_path):
return {
"setup_complete": False,
"proxmox_node": "pve",
"proxmox_storage": "hitachi",
"proxmox_storage": "backup-store",
"local_backup_dir": str(tmp_path),
"rclone_path": "/usr/bin/rclone",
"rclone_remote": "onedrive",
@@ -31,12 +31,12 @@ def _job():
return create_job(
{
"guest_vmid": 110,
"guest_name": "adguard",
"guest_name": "test-guest",
"guest_type": "vm",
"node": "pve",
"enabled": True,
"cron_schedule": "0 2 * * *",
"proxmox_storage": "hitachi",
"proxmox_storage": "backup-store",
"backup_mode": "snapshot",
"compression": "zstd",
"retention_type": "latest",
@@ -97,7 +97,7 @@ def test_pve_running_without_upid_fails_without_polling_none(isolated_db, no_not
conn.execute(
"""
INSERT INTO backups(id, guest_vmid, guest_name, guest_type, node, state, started_at, updated_at)
VALUES ('missing-upid', 110, 'adguard', 'lxc', 'astrid', 'pve_running', ?, ?)
VALUES ('missing-upid', 110, 'test-guest', 'lxc', 'pve', 'pve_running', ?, ?)
""",
(utc_now(), utc_now()),
)
@@ -156,7 +156,7 @@ def test_retention_latest_selects_expired_remote_backups(
id, job_id, guest_vmid, guest_name, guest_type, node, state,
remote_path, started_at, completed_at, updated_at
)
VALUES (?, ?, 110, 'adguard', 'vm', 'pve', 'completed', ?, ?, ?, ?)
VALUES (?, ?, 110, 'test-guest', 'vm', 'pve', 'completed', ?, ?, ?, ?)
""",
(
backup_id,
@@ -196,7 +196,7 @@ def test_startup_recovery_resumes_known_states(isolated_db, no_notifications, mo
conn.execute(
"""
INSERT INTO backups(id, guest_vmid, guest_name, guest_type, node, state, started_at, updated_at)
VALUES (?, 110, 'adguard', 'vm', 'pve', ?, ?, ?)
VALUES (?, 110, 'test-guest', 'vm', 'pve', ?, ?, ?)
""",
(backup_id, state, utc_now(), utc_now()),
)
@@ -227,7 +227,7 @@ def test_retention_sweep_applies_all_jobs_with_completed_remote_backups(
id, job_id, guest_vmid, guest_name, guest_type, node, state,
remote_path, started_at, completed_at, updated_at
)
VALUES ('sweep-test', ?, 110, 'adguard', 'vm', 'pve', 'completed',
VALUES ('sweep-test', ?, 110, 'test-guest', 'vm', 'pve', 'completed',
'onedrive:pve-cloud-backup/sweep-test/archive.tar.zst', ?, ?, ?)
""",
(job["id"], utc_now(), utc_now(), utc_now()),
@@ -260,7 +260,7 @@ def test_manual_backup_delete_removes_remote_and_known_local_file(
id, guest_vmid, guest_name, guest_type, node, state,
local_path, remote_path, started_at, completed_at, updated_at
)
VALUES ('manual-delete', 110, 'adguard', 'vm', 'pve', 'completed',
VALUES ('manual-delete', 110, 'test-guest', 'vm', 'pve', 'completed',
?, 'onedrive:pve-cloud-backup/manual-delete/archive.tar.zst', ?, ?, ?)
""",
(str(local_file), utc_now(), utc_now(), utc_now()),
@@ -303,7 +303,7 @@ def test_manual_backup_delete_removes_empty_remote_folder_when_file_is_already_m
id, guest_vmid, guest_name, guest_type, node, state,
remote_path, started_at, completed_at, updated_at
)
VALUES ('missing-remote-file', 110, 'adguard', 'vm', 'pve', 'completed',
VALUES ('missing-remote-file', 110, 'test-guest', 'vm', 'pve', 'completed',
'onedrive:pve-cloud-backup/missing-remote-file/archive.tar.zst', ?, ?, ?)
""",
(utc_now(), utc_now(), utc_now()),
@@ -327,7 +327,7 @@ def test_manual_backup_delete_refuses_active_backup(isolated_db, no_notification
conn.execute(
"""
INSERT INTO backups(id, guest_vmid, guest_name, guest_type, node, state, started_at, updated_at)
VALUES ('active-delete', 110, 'adguard', 'vm', 'pve', 'uploading', ?, ?)
VALUES ('active-delete', 110, 'test-guest', 'vm', 'pve', 'uploading', ?, ?)
""",
(utc_now(), utc_now()),
)
@@ -346,7 +346,7 @@ def test_deleting_already_deleted_backup_purges_metadata_row(isolated_db, no_not
id, guest_vmid, guest_name, guest_type, node, state,
remote_path, started_at, deleted_at, updated_at
)
VALUES ('purge-deleted', 110, 'adguard', 'vm', 'pve', 'deleted',
VALUES ('purge-deleted', 110, 'test-guest', 'vm', 'pve', 'deleted',
'onedrive:pve-cloud-backup/purge-deleted/archive.tar.zst', ?, ?, ?)
""",
(utc_now(), utc_now(), utc_now()),
@@ -380,7 +380,7 @@ def test_delete_job_deletes_backups_before_removing_job(
conn.execute(
"""
INSERT INTO backups(id, job_id, guest_vmid, guest_name, guest_type, node, state, remote_path, started_at, completed_at, updated_at)
VALUES ('job-delete-backup', ?, 110, 'adguard', 'vm', 'pve', 'completed',
VALUES ('job-delete-backup', ?, 110, 'test-guest', 'vm', 'pve', 'completed',
'onedrive:pve-cloud-backup/job-delete-backup/archive.tar.zst', ?, ?, ?)
""",
(job["id"], utc_now(), utc_now(), utc_now()),
+5 -5
View File
@@ -19,7 +19,7 @@ def test_start_proxmox_backup_parses_upid(monkeypatch):
assert commands.start_proxmox_backup(
node="pve",
vmid=110,
storage="hitachi",
storage="backup-store",
mode="snapshot",
compression="zstd",
) == expected
@@ -33,7 +33,7 @@ def test_start_proxmox_backup_parses_plain_upid(monkeypatch):
assert commands.start_proxmox_backup(
node="pve",
vmid=110,
storage="hitachi",
storage="backup-store",
mode="snapshot",
compression="zstd",
) == expected
@@ -48,7 +48,7 @@ def test_start_proxmox_backup_parses_upid_after_info_lines(monkeypatch):
assert commands.start_proxmox_backup(
node="pve",
vmid=110,
storage="hitachi",
storage="backup-store",
mode="snapshot",
compression="zstd",
) == expected
@@ -56,7 +56,7 @@ def test_start_proxmox_backup_parses_upid_after_info_lines(monkeypatch):
def test_list_guests_normalizes_vm_and_lxc(monkeypatch):
payload = [
{"vmid": "110", "name": "adguard", "type": "qemu", "node": "pve", "status": "running"},
{"vmid": "110", "name": "test-guest", "type": "qemu", "node": "pve", "status": "running"},
{"vmid": "111", "name": "ct", "type": "lxc", "node": "pve", "status": "stopped"},
]
@@ -65,7 +65,7 @@ def test_list_guests_normalizes_vm_and_lxc(monkeypatch):
guests = commands.list_guests()
assert guests == [
{"vmid": 110, "name": "adguard", "type": "vm", "node": "pve", "status": "running"},
{"vmid": 110, "name": "test-guest", "type": "vm", "node": "pve", "status": "running"},
{"vmid": 111, "name": "ct", "type": "lxc", "node": "pve", "status": "stopped"},
]
+4 -4
View File
@@ -9,8 +9,8 @@ def test_plain_onedrive_remote_is_accepted(monkeypatch):
{
"setup_complete": True,
"proxmox_node": "pve",
"proxmox_storage": "hitachi",
"local_backup_dir": "/mnt/pve/hitachi/dump",
"proxmox_storage": "backup-store",
"local_backup_dir": "/mnt/pve/backups/dump",
"rclone_path": "/usr/bin/rclone",
"rclone_remote": "onedrive",
"rclone_remote_path": "Backups/Proxmox",
@@ -31,8 +31,8 @@ def test_invalid_timezone_is_rejected(monkeypatch):
{
"setup_complete": True,
"proxmox_node": "pve",
"proxmox_storage": "hitachi",
"local_backup_dir": "/mnt/pve/hitachi/dump",
"proxmox_storage": "backup-store",
"local_backup_dir": "/mnt/pve/backups/dump",
"rclone_path": "/usr/bin/rclone",
"rclone_remote": "onedrive",
"rclone_remote_path": "Backups/Proxmox",