Skip to content

Commit e8b5452

Browse files
committed
Fix test_backup_remove_error test
1 parent d6520de commit e8b5452

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tests/backups/test_manager.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,12 +1734,20 @@ async def test_backup_remove_error(
17341734
healthy_expected: bool,
17351735
):
17361736
"""Test removing a backup error."""
1737-
copy(get_fixture_path("backup_example.tar"), coresys.config.path_backup)
1738-
await coresys.backups.reload(location=None, filename="backup_example.tar")
1737+
backup_file = get_fixture_path("backup_example.tar")
1738+
if location_name is None:
1739+
copy(backup_file, coresys.config.path_backup)
1740+
location = None
1741+
else:
1742+
(mount_dir := coresys.config.path_mounts / location_name).mkdir()
1743+
copy(backup_file, mount_dir)
1744+
location = coresys.mounts.get(location_name)
1745+
await coresys.backups.reload(location=location, filename="backup_example.tar")
17391746
assert (backup := coresys.backups.get("7fed74c8"))
17401747

1741-
backup.all_locations[location_name] = (tar_mock := MagicMock())
1742-
tar_mock.unlink.side_effect = (err := OSError())
1748+
assert location_name in backup.all_locations
1749+
backup.all_locations[location_name]["path"] = (tar_file_mock := MagicMock())
1750+
tar_file_mock.unlink.side_effect = (err := OSError())
17431751

17441752
err.errno = errno.EBUSY
17451753
assert coresys.backups.remove(backup) is False

0 commit comments

Comments
 (0)