Commit 7715f68a authored by James Valleroy's avatar James Valleroy

backups: Implement process manifests for Packet

Signed-off-by: James Valleroy's avatarJames Valleroy <jvalleroy@mailbox.org>
parent addcc4b9
...@@ -88,8 +88,11 @@ class Packet: ...@@ -88,8 +88,11 @@ class Packet:
def _process_manifests(self): def _process_manifests(self):
"""Look at manifests and fill up the list of directories/files.""" """Look at manifests and fill up the list of directories/files."""
# XXX: for manifest in self.manifests:
pass backup = manifest[2]
for x in ['config', 'data', 'secrets']:
self.directories += backup[x]['directories']
self.files += backup[x]['files']
def backup_full(backup_handler): def backup_full(backup_handler):
......
...@@ -21,12 +21,46 @@ Tests for backups module. ...@@ -21,12 +21,46 @@ Tests for backups module.
import unittest import unittest
from plinth.module_loader import load_modules from plinth.module_loader import load_modules
from ..backups import _list_of_all_apps_for_backup, _get_apps_in_order from ..backups import _list_of_all_apps_for_backup, _get_apps_in_order, \
Packet, validate
def _get_test_manifest(name):
return validate({
'config': {
'directories': ['/etc/' + name + '/config.d/'],
'files': ['/etc/' + name + '/config'],
},
'data': {
'directories': ['/var/lib/' + name + '/data.d/'],
'files': ['/var/lib/' + name + '/data'],
},
'secrets': {
'directories': ['/etc/' + name + '/secrets.d/'],
'files': ['/etc/' + name + '/secrets'],
},
'services': [name]
})
class TestBackups(unittest.TestCase): class TestBackups(unittest.TestCase):
"""Test cases for backups module.""" """Test cases for backups module."""
def test_packet_process_manifests(self):
"""Test that directories/files are collected from manifests."""
manifests = [
('a', None, _get_test_manifest('a')),
('b', None, _get_test_manifest('b')),
]
packet = Packet('backup', 'apps', '/', manifests)
for manifest in manifests:
backup = manifest[2]
for x in ['config', 'data', 'secrets']:
for d in backup[x]['directories']:
assert d in packet.directories
for f in backup[x]['files']:
assert f in packet.files
def test__list_of_all_apps_for_backups(self): def test__list_of_all_apps_for_backups(self):
"""Test that apps supporting backup are included in returned list.""" """Test that apps supporting backup are included in returned list."""
load_modules() load_modules()
......
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