def _test_backup_and_restore_app(mocker, app): # Create a backup of this app with message(mocker, "backup_created"): backup_create(system=None, apps=[app]) archives = backup_list()["archives"] assert len(archives) == 1 archives_info = backup_info(archives[0], with_details=True) assert archives_info["system"] == {} assert len(archives_info["apps"].keys()) == 1 assert app in archives_info["apps"].keys() # Uninstall the app app_remove(app) assert not app_is_installed(app) assert app + ".main" not in user_permission_list()["permissions"] # Restore the app with message(mocker, "restore_complete"): backup_restore(system=None, name=archives[0], apps=[app]) assert app_is_installed(app) # Check permission per_list = user_permission_list()["permissions"] assert app + ".main" in per_list
def test_backup_and_restore_all_sys(mocker): # Create the backup with message(mocker, "backup_created"): backup_create(system=[], apps=None) archives = backup_list()["archives"] assert len(archives) == 1 archives_info = backup_info(archives[0], with_details=True) assert archives_info["apps"] == {} assert len(archives_info["system"].keys()) == len( os.listdir("/usr/share/yunohost/hooks/backup/") ) # Remove ssowat conf assert os.path.exists("/etc/ssowat/conf.json") os.system("rm -rf /etc/ssowat/") assert not os.path.exists("/etc/ssowat/conf.json") # Restore the backup with message(mocker, "restore_complete"): backup_restore(name=archives[0], force=True, system=[], apps=None) # Check ssowat conf is back assert os.path.exists("/etc/ssowat/conf.json")
def test_backup_only_ldap(mocker): # Create the backup with message(mocker, "backup_created"): backup_create(system=["conf_ldap"], apps=None) archives = backup_list()["archives"] assert len(archives) == 1 archives_info = backup_info(archives[0], with_details=True) assert archives_info["apps"] == {} assert len(archives_info["system"].keys()) == 1 assert "conf_ldap" in archives_info["system"].keys()
def test_backup_with_different_output_directory(mocker): # Create the backup with message(mocker, "backup_created"): backup_create(system=["conf_ssh"], apps=None, output_directory="/opt/test_backup_output_directory", name="backup") assert os.path.exists("/opt/test_backup_output_directory/backup.tar") archives = backup_list()["archives"] assert len(archives) == 1 archives_info = backup_info(archives[0], with_details=True) assert archives_info["apps"] == {} assert len(archives_info["system"].keys()) == 1 assert "conf_ssh" in archives_info["system"].keys()