From ac10458a7084dd209c91fb2a18cfed1a0e8f3b23 Mon Sep 17 00:00:00 2001 From: Kristjan Eimre Date: Thu, 11 Jan 2024 12:42:40 +0200 Subject: [PATCH] adapt tests --- tests/test_backup.py | 8 ++++---- tests/test_cli.py | 23 ----------------------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/tests/test_backup.py b/tests/test_backup.py index 600136f..a8b199f 100644 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -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) @@ -38,7 +38,7 @@ 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) @@ -46,14 +46,14 @@ 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) diff --git a/tests/test_cli.py b/tests/test_cli.py index 0162652..5b7e2b9 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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" )