From 2f844d65d53c3c3e121e096fac5c31eb7a1ebd16 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 2 Jul 2024 23:11:58 -0700 Subject: [PATCH] Automated tests complete (#298). --- NEWS | 2 +- tests/unit/commands/test_borgmatic.py | 40 +++++++++++++++++++++++++++ tests/unit/hooks/test_uptimekuma.py | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index a1e9fa88..53930f37 100644 --- a/NEWS +++ b/NEWS @@ -3,7 +3,7 @@ * #785: Add an "only_run_on" option to consistency checks so you can limit a check to running on particular days of the week. See the documentation for more information: https://torsion.org/borgmatic/docs/how-to/deal-with-very-large-backups/#check-days - * #885: Add Uptime Kuma monitoring hook. See the documentation for more information: + * #885: Add an Uptime Kuma monitoring hook. See the documentation for more information: https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/#uptime-kuma-hook * #886: Fix a PagerDuty hook traceback with Python < 3.10. * #889: Fix the Healthchecks ping body size limit, restoring it to the documented 100,000 bytes. diff --git a/tests/unit/commands/test_borgmatic.py b/tests/unit/commands/test_borgmatic.py index 617da617..29d7920a 100644 --- a/tests/unit/commands/test_borgmatic.py +++ b/tests/unit/commands/test_borgmatic.py @@ -978,6 +978,46 @@ def test_run_actions_runs_export_key(): ) +def test_run_actions_runs_delete(): + flexmock(module).should_receive('add_custom_log_levels') + flexmock(module).should_receive('get_skip_actions').and_return([]) + flexmock(module.command).should_receive('execute_hook') + flexmock(borgmatic.actions.delete).should_receive('run_delete').once() + + tuple( + module.run_actions( + arguments={'global': flexmock(dry_run=False, log_file='foo'), 'delete': flexmock()}, + config_filename=flexmock(), + config={'repositories': []}, + config_paths=[], + local_path=flexmock(), + remote_path=flexmock(), + local_borg_version=flexmock(), + repository={'path': 'repo'}, + ) + ) + + +def test_run_actions_runs_rdelete(): + flexmock(module).should_receive('add_custom_log_levels') + flexmock(module).should_receive('get_skip_actions').and_return([]) + flexmock(module.command).should_receive('execute_hook') + flexmock(borgmatic.actions.rdelete).should_receive('run_rdelete').once() + + tuple( + module.run_actions( + arguments={'global': flexmock(dry_run=False, log_file='foo'), 'rdelete': flexmock()}, + config_filename=flexmock(), + config={'repositories': []}, + config_paths=[], + local_path=flexmock(), + remote_path=flexmock(), + local_borg_version=flexmock(), + repository={'path': 'repo'}, + ) + ) + + def test_run_actions_runs_borg(): flexmock(module).should_receive('add_custom_log_levels') flexmock(module).should_receive('get_skip_actions').and_return([]) diff --git a/tests/unit/hooks/test_uptimekuma.py b/tests/unit/hooks/test_uptimekuma.py index 05d58028..98bd3158 100644 --- a/tests/unit/hooks/test_uptimekuma.py +++ b/tests/unit/hooks/test_uptimekuma.py @@ -136,7 +136,7 @@ def test_ping_monitor_with_other_error_logs_warning(): response.should_receive('raise_for_status').and_raise( module.requests.exceptions.RequestException ) - flexmock(module.requests).should_receive('post').with_args( + flexmock(module.requests).should_receive('get').with_args( f'{CUSTOM_PUSH_URL}?status=down&msg=fail' ).and_return(response) flexmock(module.logger).should_receive('warning').once()