瀏覽代碼

added test for value error

Antonio Fernandez 7 月之前
父節點
當前提交
dab0dfcb32
共有 2 個文件被更改,包括 11 次插入11 次删除
  1. 1 2
      borgmatic/hooks/pushover.py
  2. 10 9
      tests/unit/hooks/test_pushover.py

+ 1 - 2
borgmatic/hooks/pushover.py

@@ -51,8 +51,7 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev
             )
 
     state_config = {
-        key: (int(value) if key in 'html' else value)
-        for key, value in state_config.items()
+        key: (int(value) if key in 'html' else value) for key, value in state_config.items()
     }
 
     data = dict(

+ 10 - 9
tests/unit/hooks/test_pushover.py

@@ -1,3 +1,4 @@
+import pytest
 from flexmock import flexmock
 
 import borgmatic.hooks.monitor
@@ -237,15 +238,15 @@ def test_ping_monitor_start_state_backup_default_message_with_priority_high_decl
 
     flexmock(module.logger).should_receive('warning').never()
     flexmock(module.requests).should_receive('post').never()
-
-    module.ping_monitor(
-        hook_config,
-        {},
-        'config.yaml',
-        borgmatic.hooks.monitor.State.START,
-        monitoring_log_level=1,
-        dry_run=False,
-    )
+    with pytest.raises(ValueError):
+        module.ping_monitor(
+            hook_config,
+            {},
+            'config.yaml',
+            borgmatic.hooks.monitor.State.START,
+            monitoring_log_level=1,
+            dry_run=False,
+        )
 
 
 def test_ping_monitor_start_state_backup_based_on_documentation_advanced_example_success():