From d556a23f97be17c7658c21632c7e9bb7595b7589 Mon Sep 17 00:00:00 2001 From: Soumik Dutta Date: Fri, 12 May 2023 20:00:11 +0530 Subject: [PATCH] update borgmatic tests Signed-off-by: Soumik Dutta --- tests/unit/commands/test_borgmatic.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/unit/commands/test_borgmatic.py b/tests/unit/commands/test_borgmatic.py index bd98c01..144de18 100644 --- a/tests/unit/commands/test_borgmatic.py +++ b/tests/unit/commands/test_borgmatic.py @@ -169,6 +169,20 @@ def test_run_configuration_bails_for_monitor_finish_soft_failure(): assert results == [] +def test_run_configuration_does_not_call_monitoring_hooks_if_monitoring_hooks_are_disabled(): + flexmock(module).should_receive('verbosity_to_log_level').and_return(module.DISABLED) + flexmock(module.borg_version).should_receive('local_borg_version').and_return(flexmock()) + + flexmock(module.dispatch).should_receive('call_hooks').never() + flexmock(module).should_receive('run_actions').and_return([]) + flexmock(module.dispatch).should_receive('call_hooks').never() + + config = {'location': {'repositories': [{'path': 'foo'}]}} + arguments = {'global': flexmock(monitoring_verbosity=-2, dry_run=False), 'create': flexmock()} + results = list(module.run_configuration('test.yaml', config, arguments)) + assert results == [] + + def test_run_configuration_logs_on_error_hook_error(): flexmock(module).should_receive('verbosity_to_log_level').and_return(logging.INFO) flexmock(module.borg_version).should_receive('local_borg_version').and_return(flexmock()) @@ -229,8 +243,7 @@ def test_run_configuration_retries_hard_error(): ).and_return([flexmock()]) error_logs = [flexmock()] flexmock(module).should_receive('log_error_records').with_args( - 'foo: Error running actions for repository', - OSError, + 'foo: Error running actions for repository', OSError, ).and_return(error_logs) config = {'location': {'repositories': [{'path': 'foo'}]}, 'storage': {'retries': 1}} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}