Skip to content

Commit

Permalink
adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eimrek committed Jan 11, 2024
1 parent a79f73a commit ac10458
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
8 changes: 4 additions & 4 deletions tests/test_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _random_string(n=10):
def test_invalid_destination():
"""Test invalid destination with two colons."""
dest = "localhost:/tmp/test:"
with pytest.raises(BackupError, match="Invalid destination format"):
with pytest.raises(ValueError, match="Invalid destination format"):
BackupManager(dest, backup_utils.backup_logger)


Expand All @@ -38,22 +38,22 @@ def test_inaccessible_remote():
def test_negative_keep():
"""Test a negative keep value."""
dest = "/tmp/test"
with pytest.raises(BackupError, match="keep variable can't be negative"):
with pytest.raises(ValueError, match="keep variable can't be negative"):
BackupManager(dest, backup_utils.backup_logger, keep=-1)


def test_inaccessible_exe():
"""Test case where rsync is not accessible."""
dest = "/tmp/test"
rsync_exe = f"_{_random_string()}"
with pytest.raises(BackupError, match=f"{rsync_exe} not accessible."):
with pytest.raises(ValueError, match=f"{rsync_exe} not accessible."):
BackupManager(dest, backup_utils.backup_logger, exes={"rsync": rsync_exe})


def test_inaccessible_path():
"""Test case where path is not accessible."""
dest = f"/_{_random_string()}" # I assume there will be a permission error for this path
with pytest.raises(BackupError, match=f"Couldn't access/create '{dest}'"):
with pytest.raises(ValueError, match=f"Couldn't access/create '{dest}'"):
BackupManager(dest, backup_utils.backup_logger)


Expand Down
23 changes: 0 additions & 23 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,29 +288,6 @@ def test_backup_repeated(temp_container, temp_dir, remote):
assert len(backup_dirs) == 2


@pytest.mark.skipif(
platform.system() == "Windows", reason="Backup not supported on Windows"
)
def test_backup_unsupported_verbosity(temp_container, temp_dir):
"""Test failure when providing unsupported verbosity value"""

temp_container.init_container(clear=True)
# Add a few objects
for idx in range(100):
temp_container.add_object(f"test-{idx}".encode())

obj = cli.ContainerContext(temp_container.get_folder())

path = Path(temp_dir) / "backup"

args = [str(path), "--verbosity=unsupported"]

result = CliRunner().invoke(cli.backup, args, obj=obj)

assert result.exit_code == 1
assert "Unsupported verbosity" in result.stdout


@pytest.mark.skipif(
platform.system() == "Windows", reason="Backup not supported on Windows"
)
Expand Down

0 comments on commit ac10458

Please sign in to comment.