From dc781b03faaa282a473857042bfe5d289cf3de24 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Sun, 23 Sep 2018 07:33:09 -0700 Subject: [PATCH] backups: Make getting all apps method public Signed-off-by: Joseph Nuthalapati --- plinth/modules/backups/backups.py | 6 +++--- plinth/modules/backups/forms.py | 4 ++-- plinth/modules/backups/tests/test_backups.py | 6 +++--- plinth/modules/backups/views.py | 7 ++++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/plinth/modules/backups/backups.py b/plinth/modules/backups/backups.py index 36e834176..c202fba1c 100644 --- a/plinth/modules/backups/backups.py +++ b/plinth/modules/backups/backups.py @@ -126,7 +126,7 @@ def restore_full(restore_handler): def backup_apps(backup_handler, app_names=None, label=None): """Backup data belonging to a set of applications.""" if not app_names: - apps = _list_of_all_apps_for_backup() + apps = get_all_apps_for_backup() else: apps = _get_apps_in_order(app_names) @@ -156,7 +156,7 @@ def restore_apps(restore_handler, app_names=None, create_subvolume=True, backup_file=None): """Restore data belonging to a set of applications.""" if not app_names: - apps = _list_of_all_apps_for_backup() + apps = get_all_apps_for_backup() else: apps = _get_apps_in_order(app_names) @@ -182,7 +182,7 @@ def restore_apps(restore_handler, app_names=None, create_subvolume=True, _lockdown_apps(apps, lockdown=False) -def _list_of_all_apps_for_backup(): +def get_all_apps_for_backup(): """Return a list of all applications that can be backed up.""" apps = [] for module_name, module in module_loader.loaded_modules.items(): diff --git a/plinth/modules/backups/forms.py b/plinth/modules/backups/forms.py index b94aea999..5685a8529 100644 --- a/plinth/modules/backups/forms.py +++ b/plinth/modules/backups/forms.py @@ -22,8 +22,8 @@ from django import forms from django.core import validators from django.utils.translation import ugettext_lazy as _ +from . import backups as backups_api from . import get_export_locations -from .backups import _list_of_all_apps_for_backup class CreateArchiveForm(forms.Form): @@ -41,7 +41,7 @@ class CreateArchiveForm(forms.Form): def __init__(self, *args, **kwargs): """Initialize the form with selectable apps.""" super().__init__(*args, **kwargs) - apps = _list_of_all_apps_for_backup() + apps = backups_api.get_all_apps_for_backup() self.fields['selected_apps'].choices = [ (app[0], app[1].name) for app in apps] self.fields['selected_apps'].initial = [app[0] for app in apps] diff --git a/plinth/modules/backups/tests/test_backups.py b/plinth/modules/backups/tests/test_backups.py index 75dedb6bd..272bc2740 100644 --- a/plinth/modules/backups/tests/test_backups.py +++ b/plinth/modules/backups/tests/test_backups.py @@ -24,7 +24,7 @@ from unittest.mock import call, patch, MagicMock from plinth.module_loader import load_modules from ..backups import validate, Packet, backup_apps, restore_apps, \ - _list_of_all_apps_for_backup, _get_apps_in_order, _get_manifests, \ + get_all_apps_for_backup, _get_apps_in_order, _get_manifests, \ _lockdown_apps, _shutdown_services, _restore_services @@ -76,10 +76,10 @@ class TestBackups(unittest.TestCase): restore_apps(restore_handler) restore_handler.assert_called_once() - def test__list_of_all_apps_for_backups(self): + def test_get_all_apps_for_backups(self): """Test that apps supporting backup are included in returned list.""" load_modules() - apps = _list_of_all_apps_for_backup() + apps = get_all_apps_for_backup() assert isinstance(apps, list) # apps may be empty, if no apps supporting backup are installed. diff --git a/plinth/modules/backups/views.py b/plinth/modules/backups/views.py index f5bfe75d4..f2253161c 100644 --- a/plinth/modules/backups/views.py +++ b/plinth/modules/backups/views.py @@ -30,8 +30,9 @@ from django.views.generic import FormView, TemplateView from urllib.parse import unquote from plinth.modules import backups + +from . import backups as backups_api from . import find_exported_archive, get_export_apps -from .backups import _list_of_all_apps_for_backup from .forms import CreateArchiveForm, ExportArchiveForm, RestoreForm @@ -47,7 +48,7 @@ class IndexView(TemplateView): context['info'] = backups.get_info() context['archives'] = backups.list_archives() context['exports'] = backups.get_export_files() - apps = _list_of_all_apps_for_backup() + apps = backups_api.get_all_apps_for_backup() context['available_apps'] = [x[0] for x in apps] return context @@ -139,7 +140,7 @@ class RestoreView(SuccessMessageMixin, FormView): self.label = unquote(label) self.name = unquote(name) self.filename = find_exported_archive(self.label, self.name) - self.installed_apps = _list_of_all_apps_for_backup() + self.installed_apps = backups_api.get_all_apps_for_backup() self.included_apps = get_export_apps(self.filename) def get(self, request, *args, **kwargs):