Verified Commit bbb80fe5 authored by Sunil Mohan Adapa's avatar Sunil Mohan Adapa Committed by James Valleroy

tests: Fix backups API test cases to work under all conditions

Ensure that loaded module list is mocked instead of actually loading modules.
Signed-off-by: Sunil Mohan Adapa's avatarSunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy's avatarJames Valleroy <jvalleroy@mailbox.org>
parent 0e231548
......@@ -111,8 +111,10 @@ class TestBackupProcesses(unittest.TestCase):
@staticmethod
@patch('plinth.modules.backups.api._install_apps_before_restore')
def test_restore_apps(mock_install):
@patch('plinth.module_loader.loaded_modules.items')
def test_restore_apps(mock_install, modules):
"""Test that restore_handler is called."""
modules.return_value = [('a', MagicMock())]
restore_handler = MagicMock()
api.restore_apps(restore_handler)
restore_handler.assert_called_once()
......@@ -129,7 +131,6 @@ class TestBackupProcesses(unittest.TestCase):
del apps[3][1].backup
modules.return_value = apps
module_loader.load_modules()
returned_apps = api.get_all_apps_for_backup()
expected_apps = [
api.BackupApp('a', apps[0][1]),
......@@ -148,7 +149,6 @@ class TestBackupProcesses(unittest.TestCase):
]
modules.return_value = apps
module_loader.load_modules()
app_names = ['config', 'names']
apps = api.get_apps_in_order(app_names)
assert apps[0].name == 'names'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment