From 962267b3c5b3888d0ef984c0717f9e270c77dfb1 Mon Sep 17 00:00:00 2001 From: Divyansh Singh Date: Tue, 1 Aug 2023 02:26:36 +0530 Subject: [PATCH] add test for checking manifest creation --- tests/unit/actions/test_create.py | 35 +++++++++++++++++++++++++++++++ tests/unit/borg/test_create.py | 6 +++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/tests/unit/actions/test_create.py b/tests/unit/actions/test_create.py index 355e544a..fbd974c8 100644 --- a/tests/unit/actions/test_create.py +++ b/tests/unit/actions/test_create.py @@ -39,6 +39,41 @@ def test_run_create_executes_and_calls_hooks_for_configured_repository(): ) ) +def test_run_create_with_store_config_files_false_does_not_create_borgmatic_manifest(): + flexmock(module.logger).answer = lambda message: None + flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never() + flexmock(module.borgmatic.borg.create).should_receive('create_archive').once() + flexmock(module).should_receive('create_borgmatic_manifest').never() + flexmock(module.borgmatic.hooks.command).should_receive('execute_hook').times(2) + flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks').and_return({}) + flexmock(module.borgmatic.hooks.dispatch).should_receive( + 'call_hooks_even_if_unconfigured' + ).and_return({}) + create_arguments = flexmock( + repository=None, + progress=flexmock(), + stats=flexmock(), + json=flexmock(), + list_files=flexmock(), + ) + global_arguments = flexmock(monitoring_verbosity=1, dry_run=False, used_config_paths=[]) + + list( + module.run_create( + config_filename='test.yaml', + repository={'path': 'repo'}, + config={ + 'store_config_files': False + }, + hook_context={}, + local_borg_version=None, + create_arguments=create_arguments, + global_arguments=global_arguments, + dry_run_label='', + local_path=None, + remote_path=None, + ) + ) def test_run_create_runs_with_selected_repository(): flexmock(module.logger).answer = lambda message: None diff --git a/tests/unit/borg/test_create.py b/tests/unit/borg/test_create.py index a07ab9ee..7f04868b 100644 --- a/tests/unit/borg/test_create.py +++ b/tests/unit/borg/test_create.py @@ -651,13 +651,13 @@ def test_create_archive_with_sources_and_used_config_paths_with_store_config_fil flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER flexmock(module).should_receive('collect_borgmatic_source_directories').and_return([]) flexmock(module).should_receive('deduplicate_directories').and_return( - ('foo', 'bar', '/etc/borgmatic/config.yaml') + ('foo', 'bar') ) flexmock(module).should_receive('map_directories_to_devices').and_return({}) flexmock(module).should_receive('expand_directories').with_args([]).and_return(()) flexmock(module).should_receive('expand_directories').with_args( - ('foo', 'bar', '/etc/borgmatic/config.yaml') - ).and_return(('foo', 'bar', '/etc/borgmatic/config.yaml')) + ('foo', 'bar') + ).and_return(('foo', 'bar')) flexmock(module).should_receive('expand_directories').with_args([]).and_return(()) flexmock(module).should_receive('pattern_root_directories').and_return([]) flexmock(module.os.path).should_receive('expanduser').and_raise(TypeError)