mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
backups: Allow comments to be added to archives during backup
Tests performed: - Schedules are able to store and retrieve comments properly. Information about schedule backups stored in comments is extracted properly. - Unit tests run. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
d3f8e815c1
commit
01e00cdde4
6 files changed
+55
-11
No files matched your search
@@ -63,11 +63,21 @@ def _get_test_app(name):
|
||||
class TestBackupProcesses:
|
||||
"""Test cases for backup processes"""
|
||||
|
||||
@staticmethod
|
||||
def test_packet_init():
|
||||
"""Test that packet is initialized properly."""
|
||||
packet = api.Packet('backup', 'apps', '/', [])
|
||||
assert packet.archive_comment is None
|
||||
packet = api.Packet('backup', 'apps', '/', [],
|
||||
archive_comment='test comment')
|
||||
assert packet.archive_comment == 'test comment'
|
||||
|
||||
@staticmethod
|
||||
def test_packet_collected_files_directories():
|
||||
"""Test that directories/files are collected from manifests."""
|
||||
components = [_get_backup_component('a'), _get_backup_component('b')]
|
||||
packet = api.Packet('backup', 'apps', '/', components)
|
||||
packet = api.Packet('backup', 'apps', '/', components,
|
||||
archive_comment='test comment')
|
||||
for component in components:
|
||||
for section in ['config', 'data', 'secrets']:
|
||||
for directory in getattr(component, section)['directories']:
|
||||
|
||||
@@ -88,18 +88,21 @@ def test_create_export_delete_archive(data_directory, backup_directory):
|
||||
"""
|
||||
repo_name = 'test_create_and_delete'
|
||||
archive_name = 'first_archive'
|
||||
archive_comment = 'test_archive_comment'
|
||||
path = backup_directory / repo_name
|
||||
|
||||
repository = BorgRepository(str(path))
|
||||
repository.initialize()
|
||||
archive_path = "::".join([str(path), archive_name])
|
||||
actions.superuser_run('backups', [
|
||||
'create-archive', '--path', archive_path, '--paths',
|
||||
'create-archive', '--path', archive_path, '--comment', archive_comment,
|
||||
'--paths',
|
||||
str(data_directory)
|
||||
])
|
||||
|
||||
archive = repository.list_archives()[0]
|
||||
assert archive['name'] == archive_name
|
||||
assert archive['comment'] == archive_comment
|
||||
|
||||
repository.delete_archive(archive_name)
|
||||
content = repository.list_archives()
|
||||
|
||||
Reference in new issue
Block a user