Switch to backups from 4.2

This commit is contained in:
Alexandre Aubin 2021-06-12 16:23:40 +02:00
parent 870bece358
commit 653d7e8127
2 changed files with 25 additions and 25 deletions

View file

@ -866,7 +866,7 @@ class RestoreManager:
# early dev for next debian version
from_version = re.sub(r'~\w+', '', from_version)
if not from_version or version.parse(from_version) < version.parse("3.8.0"):
if not from_version or version.parse(from_version) < version.parse("4.2.0"):
raise YunohostValidationError("restore_backup_too_old")
self.archive_path = self.info["path"]

View file

@ -47,8 +47,8 @@ def setup_function(function):
for m in function.__dict__.get("pytestmark", [])
}
if "with_wordpress_archive_from_3p8" in markers:
add_archive_wordpress_from_3p8()
if "with_wordpress_archive_from_4p2" in markers:
add_archive_wordpress_from_4p2()
assert len(backup_list()["archives"]) == 1
if "with_legacy_app_installed" in markers:
@ -70,8 +70,8 @@ def setup_function(function):
)
assert app_is_installed("backup_recommended_app")
if "with_system_archive_from_3p8" in markers:
add_archive_system_from_3p8()
if "with_system_archive_from_4p2" in markers:
add_archive_system_from_4p2()
assert len(backup_list()["archives"]) == 1
if "with_permission_app_installed" in markers:
@ -148,7 +148,7 @@ def backup_test_dependencies_are_met():
# Dummy test apps (or backup archives)
assert os.path.exists(
os.path.join(get_test_apps_dir(), "backup_wordpress_from_3p8")
os.path.join(get_test_apps_dir(), "backup_wordpress_from_4p2")
)
assert os.path.exists(os.path.join(get_test_apps_dir(), "legacy_app_ynh"))
assert os.path.exists(
@ -217,25 +217,25 @@ def install_app(app, path, additionnal_args=""):
)
def add_archive_wordpress_from_3p8():
def add_archive_wordpress_from_4p2():
os.system("mkdir -p /home/yunohost.backup/archives")
os.system(
"cp "
+ os.path.join(get_test_apps_dir(), "backup_wordpress_from_3p8/backup.tar.gz")
+ " /home/yunohost.backup/archives/backup_wordpress_from_3p8.tar.gz"
+ os.path.join(get_test_apps_dir(), "backup_wordpress_from_4p2/backup.tar")
+ " /home/yunohost.backup/archives/backup_wordpress_from_4p2.tar"
)
def add_archive_system_from_3p8():
def add_archive_system_from_4p2():
os.system("mkdir -p /home/yunohost.backup/archives")
os.system(
"cp "
+ os.path.join(get_test_apps_dir(), "backup_system_from_3p8/backup.tar.gz")
+ " /home/yunohost.backup/archives/backup_system_from_3p8.tar.gz"
+ os.path.join(get_test_apps_dir(), "backup_system_from_4p2/backup.tar")
+ " /home/yunohost.backup/archives/backup_system_from_4p2.tar"
)
@ -305,8 +305,8 @@ def test_backup_and_restore_all_sys(mocker):
#
@pytest.mark.with_system_archive_from_3p8
def test_restore_system_from_Ynh3p8(monkeypatch, mocker):
@pytest.mark.with_system_archive_from_4p2
def test_restore_system_from_Ynh4p2(monkeypatch, mocker):
# Backup current system
with message(mocker, "backup_created"):
@ -451,9 +451,9 @@ def test_backup_using_copy_method(mocker):
#
@pytest.mark.with_wordpress_archive_from_3p8
@pytest.mark.with_wordpress_archive_from_4p2
@pytest.mark.with_custom_domain("yolo.test")
def test_restore_app_wordpress_from_Ynh3p8(mocker):
def test_restore_app_wordpress_from_Ynh4p2(mocker):
with message(mocker, "restore_complete"):
backup_restore(
@ -461,7 +461,7 @@ def test_restore_app_wordpress_from_Ynh3p8(mocker):
)
@pytest.mark.with_wordpress_archive_from_3p8
@pytest.mark.with_wordpress_archive_from_4p2
@pytest.mark.with_custom_domain("yolo.test")
def test_restore_app_script_failure_handling(monkeypatch, mocker):
def custom_hook_exec(name, *args, **kwargs):
@ -482,7 +482,7 @@ def test_restore_app_script_failure_handling(monkeypatch, mocker):
assert not _is_installed("wordpress")
@pytest.mark.with_wordpress_archive_from_3p8
@pytest.mark.with_wordpress_archive_from_4p2
def test_restore_app_not_enough_free_space(monkeypatch, mocker):
def custom_free_space_in_directory(dirpath):
return 0
@ -501,7 +501,7 @@ def test_restore_app_not_enough_free_space(monkeypatch, mocker):
assert not _is_installed("wordpress")
@pytest.mark.with_wordpress_archive_from_3p8
@pytest.mark.with_wordpress_archive_from_4p2
def test_restore_app_not_in_backup(mocker):
assert not _is_installed("wordpress")
@ -517,7 +517,7 @@ def test_restore_app_not_in_backup(mocker):
assert not _is_installed("yoloswag")
@pytest.mark.with_wordpress_archive_from_3p8
@pytest.mark.with_wordpress_archive_from_4p2
@pytest.mark.with_custom_domain("yolo.test")
def test_restore_app_already_installed(mocker):
@ -627,7 +627,7 @@ def test_restore_archive_with_no_json(mocker):
# Create a backup with no info.json associated
os.system("touch /tmp/afile")
os.system("tar -czvf /home/yunohost.backup/archives/badbackup.tar.gz /tmp/afile")
os.system("tar -cvf /home/yunohost.backup/archives/badbackup.tar /tmp/afile")
assert "badbackup" in backup_list()["archives"]
@ -635,18 +635,18 @@ def test_restore_archive_with_no_json(mocker):
backup_restore(name="badbackup", force=True)
@pytest.mark.with_wordpress_archive_from_3p8
@pytest.mark.with_wordpress_archive_from_4p2
def test_restore_archive_with_bad_archive(mocker):
# Break the archive
os.system(
"head -n 1000 /home/yunohost.backup/archives/backup_wordpress_from_3p8.tar.gz > /home/yunohost.backup/archives/backup_wordpress_from_3p8_bad.tar.gz"
"head -n 1000 /home/yunohost.backup/archives/backup_wordpress_from_4p2.tar > /home/yunohost.backup/archives/backup_wordpress_from_4p2_bad.tar"
)
assert "backup_wordpress_from_3p8_bad" in backup_list()["archives"]
assert "backup_wordpress_from_4p2_bad" in backup_list()["archives"]
with raiseYunohostError(mocker, "backup_archive_corrupted"):
backup_restore(name="backup_wordpress_from_3p8_bad", force=True)
backup_restore(name="backup_wordpress_from_4p2_bad", force=True)
clean_tmp_backup_directory()