aboutsummaryrefslogtreecommitdiffstats
path: root/molecule/default/tests/test_manual_backup.py
diff options
context:
space:
mode:
authorColin Wilk <colin@wilk.cx>2026-06-28 23:24:21 +0200
committerColin Wilk <colin@wilk.cx>2026-06-28 23:24:21 +0200
commita0432093db76d7bb462f113d4bbeca0a8f376e95 (patch)
tree1a7bd3659d22f07ed3d3dfc035d88913b85d37ed /molecule/default/tests/test_manual_backup.py
parent1143a273413e8c3df0b4c0f553eab30acb0804f8 (diff)
downloadansible-role-borgbackup-a0432093db76d7bb462f113d4bbeca0a8f376e95.tar.gz
ansible-role-borgbackup-a0432093db76d7bb462f113d4bbeca0a8f376e95.zip
Format python files with ruff
Diffstat (limited to 'molecule/default/tests/test_manual_backup.py')
-rw-r--r--molecule/default/tests/test_manual_backup.py54
1 files changed, 28 insertions, 26 deletions
diff --git a/molecule/default/tests/test_manual_backup.py b/molecule/default/tests/test_manual_backup.py
index b4068bc..8cd044c 100644
--- a/molecule/default/tests/test_manual_backup.py
+++ b/molecule/default/tests/test_manual_backup.py
@@ -1,22 +1,22 @@
import pytest
from datetime import datetime
-testinfra_hosts = ['borg-client', 'borg-client-2']
+testinfra_hosts = ["borg-client", "borg-client-2"]
def get_server_info(hostname):
- if hostname == 'borg-client-2':
- return ('backupserver', 'borg-server-2', '/var/backups')
- return ('borg', 'borg-server', '/opt/borg')
+ if hostname == "borg-client-2":
+ return ("backupserver", "borg-server-2", "/var/backups")
+ return ("borg", "borg-server", "/opt/borg")
compression_types = [
- 'none',
- 'lz4',
- 'zstd',
- 'zstd,10',
- 'zlib',
- 'zlib,6',
+ "none",
+ "lz4",
+ "zstd",
+ "zstd,10",
+ "zlib",
+ "zlib,6",
]
@@ -24,7 +24,7 @@ compression_types = [
host"""
-@pytest.mark.parametrize('compression', compression_types)
+@pytest.mark.parametrize("compression", compression_types)
def test_backup_push(host, compression):
hostname = host.backend.get_hostname()
server_user, server_host, server_path = get_server_info(hostname)
@@ -33,15 +33,15 @@ def test_backup_push(host, compression):
f'borg create -C "{compression}" {server_user}@{server_host}:{server_path}/{hostname}::testinfra-{{now:%S.%f}} /etc'
)
assert c.rc == 0
- assert c.stdout == ''
- assert c.stderr == ''
+ assert c.stdout == ""
+ assert c.stderr == ""
-@pytest.mark.parametrize('compression', compression_types)
+@pytest.mark.parametrize("compression", compression_types)
def test_backup_restore(host, compression):
hostname = host.backend.get_hostname()
server_user, server_host, server_path = get_server_info(hostname)
- timestamp = datetime.now().strftime('%Y%m%d-%H%M%S-%f')
+ timestamp = datetime.now().strftime("%Y%m%d-%H%M%S-%f")
archive_name = f"testinfra-backup-restore-{compression}-{timestamp}"
# Create backup
@@ -49,16 +49,16 @@ def test_backup_restore(host, compression):
f'borg create -C "{compression}" {server_user}@{server_host}:{server_path}/{hostname}::{archive_name} /etc'
)
assert c.rc == 0
- assert c.stdout == ''
- assert c.stderr == ''
+ assert c.stdout == ""
+ assert c.stderr == ""
# Restore Backup
c = host.run(
f"cd /mnt && borg extract {server_user}@{server_host}:{server_path}/{hostname}::{archive_name}"
)
assert c.rc == 0
- assert c.stdout == ''
- assert c.stderr == ''
+ assert c.stdout == ""
+ assert c.stderr == ""
# Check if every file exists, content has, and permissions / metadata
c1 = host.run(
@@ -68,17 +68,19 @@ def test_backup_restore(host, compression):
'cd /mnt/etc && find /etc -type f -printf "%P\\n" | sort | xargs -i sh -c "echo {}; sha512sum {} | cut -d \' \' -f 1; ls -l {}; echo"'
)
assert c1.rc == 0 and c2.rc == 0
- assert c1.stderr == '' and c2.stderr == ''
+ assert c1.stderr == "" and c2.stderr == ""
assert c1.stdout == c2.stdout
# Delete directory extract directory again for future tests
- c = host.run('rm -rf /mnt/etc')
+ c = host.run("rm -rf /mnt/etc")
assert c.rc == 0
- assert c.stdout == ''
- assert c.stderr == ''
+ assert c.stdout == ""
+ assert c.stderr == ""
# Delete backup
- c = host.run(f"borg delete {server_user}@{server_host}:{server_path}/{hostname}::{archive_name}")
+ c = host.run(
+ f"borg delete {server_user}@{server_host}:{server_path}/{hostname}::{archive_name}"
+ )
assert c.rc == 0
- assert c.stdout == ''
- assert c.stderr == ''
+ assert c.stdout == ""
+ assert c.stderr == ""