Bladeren bron

added dryrun test case with minimum config

Tony Fernandez 7 maanden geleden
bovenliggende
commit
4e1f256b48
1 gewijzigde bestanden met toevoegingen van 27 en 0 verwijderingen
  1. 27 0
      tests/unit/hooks/test_pushover.py

+ 27 - 0
tests/unit/hooks/test_pushover.py

@@ -450,3 +450,30 @@ def test_ping_monitor_finish_state_backup_based_on_documentation_advanced_exampl
         monitoring_log_level=1,
         dry_run=False,
     )
+
+
+def test_ping_monitor_config_with_minimum_config_fail_state_backup_successfully_send_to_pushover_dryrun():
+    '''
+    This test should be the minimum working configuration. The "message"
+    should be auto populated with the default value which is the state name.
+    '''
+    hook_config = {'token': 'ksdjfwoweijfvwoeifvjmwghagy92', 'user': '983hfe0of902lkjfa2amanfgui'}
+    flexmock(module.logger).should_receive('warning').never()
+    flexmock(module.requests).should_receive('post').with_args(
+        'https://api.pushover.net/1/messages.json',
+        headers={'Content-type': 'application/x-www-form-urlencoded'},
+        data={
+            'token': 'ksdjfwoweijfvwoeifvjmwghagy92',
+            'user': '983hfe0of902lkjfa2amanfgui',
+            'message': 'fail',
+        },
+    ).and_return(flexmock(ok=True)).never()
+
+    module.ping_monitor(
+        hook_config,
+        {},
+        'config.yaml',
+        borgmatic.hooks.monitor.State.FAIL,
+        monitoring_log_level=1,
+        dry_run=True,
+    )