|
@@ -2,8 +2,8 @@ import apprise
|
|
from apprise import NotifyFormat, NotifyType
|
|
from apprise import NotifyFormat, NotifyType
|
|
from flexmock import flexmock
|
|
from flexmock import flexmock
|
|
|
|
|
|
-import borgmatic.hooks.monitor
|
|
|
|
-from borgmatic.hooks import apprise as module
|
|
|
|
|
|
+import borgmatic.hooks.monitoring.monitor
|
|
|
|
+from borgmatic.hooks.monitoring import apprise as module
|
|
|
|
|
|
TOPIC = 'borgmatic-unit-testing'
|
|
TOPIC = 'borgmatic-unit-testing'
|
|
|
|
|
|
@@ -18,7 +18,7 @@ def mock_apprise():
|
|
|
|
|
|
|
|
|
|
def test_initialize_monitor_with_send_logs_false_does_not_add_handler():
|
|
def test_initialize_monitor_with_send_logs_false_does_not_add_handler():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('add_handler').never()
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('add_handler').never()
|
|
|
|
|
|
module.initialize_monitor(
|
|
module.initialize_monitor(
|
|
hook_config={'send_logs': False},
|
|
hook_config={'send_logs': False},
|
|
@@ -31,12 +31,14 @@ def test_initialize_monitor_with_send_logs_false_does_not_add_handler():
|
|
|
|
|
|
def test_initialize_monitor_with_send_logs_true_adds_handler_with_default_log_size_limit():
|
|
def test_initialize_monitor_with_send_logs_true_adds_handler_with_default_log_size_limit():
|
|
truncation_indicator_length = 4
|
|
truncation_indicator_length = 4
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('Forgetful_buffering_handler').with_args(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
|
|
+ 'Forgetful_buffering_handler'
|
|
|
|
+ ).with_args(
|
|
module.HANDLER_IDENTIFIER,
|
|
module.HANDLER_IDENTIFIER,
|
|
module.DEFAULT_LOGS_SIZE_LIMIT_BYTES - truncation_indicator_length,
|
|
module.DEFAULT_LOGS_SIZE_LIMIT_BYTES - truncation_indicator_length,
|
|
1,
|
|
1,
|
|
).once()
|
|
).once()
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('add_handler').once()
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('add_handler').once()
|
|
|
|
|
|
module.initialize_monitor(
|
|
module.initialize_monitor(
|
|
hook_config={'send_logs': True},
|
|
hook_config={'send_logs': True},
|
|
@@ -49,12 +51,14 @@ def test_initialize_monitor_with_send_logs_true_adds_handler_with_default_log_si
|
|
|
|
|
|
def test_initialize_monitor_without_send_logs_adds_handler_with_default_log_size_limit():
|
|
def test_initialize_monitor_without_send_logs_adds_handler_with_default_log_size_limit():
|
|
truncation_indicator_length = 4
|
|
truncation_indicator_length = 4
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('Forgetful_buffering_handler').with_args(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
|
|
+ 'Forgetful_buffering_handler'
|
|
|
|
+ ).with_args(
|
|
module.HANDLER_IDENTIFIER,
|
|
module.HANDLER_IDENTIFIER,
|
|
module.DEFAULT_LOGS_SIZE_LIMIT_BYTES - truncation_indicator_length,
|
|
module.DEFAULT_LOGS_SIZE_LIMIT_BYTES - truncation_indicator_length,
|
|
1,
|
|
1,
|
|
).once()
|
|
).once()
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('add_handler').once()
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('add_handler').once()
|
|
|
|
|
|
module.initialize_monitor(
|
|
module.initialize_monitor(
|
|
hook_config={},
|
|
hook_config={},
|
|
@@ -66,8 +70,8 @@ def test_initialize_monitor_without_send_logs_adds_handler_with_default_log_size
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_respects_dry_run():
|
|
def test_ping_monitor_respects_dry_run():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler')
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler')
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
'format_buffered_logs_for_payload'
|
|
'format_buffered_logs_for_payload'
|
|
).and_return('loggy log')
|
|
).and_return('loggy log')
|
|
mock_apprise().should_receive('notify').never()
|
|
mock_apprise().should_receive('notify').never()
|
|
@@ -76,30 +80,32 @@ def test_ping_monitor_respects_dry_run():
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}]},
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}]},
|
|
{},
|
|
{},
|
|
'config.yaml',
|
|
'config.yaml',
|
|
- borgmatic.hooks.monitor.State.FAIL,
|
|
|
|
|
|
+ borgmatic.hooks.monitoring.monitor.State.FAIL,
|
|
monitoring_log_level=1,
|
|
monitoring_log_level=1,
|
|
dry_run=True,
|
|
dry_run=True,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_with_no_states_does_not_notify():
|
|
def test_ping_monitor_with_no_states_does_not_notify():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler').never()
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('format_buffered_logs_for_payload').never()
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler').never()
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
|
|
+ 'format_buffered_logs_for_payload'
|
|
|
|
+ ).never()
|
|
mock_apprise().should_receive('notify').never()
|
|
mock_apprise().should_receive('notify').never()
|
|
|
|
|
|
module.ping_monitor(
|
|
module.ping_monitor(
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}], 'states': []},
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}], 'states': []},
|
|
{},
|
|
{},
|
|
'config.yaml',
|
|
'config.yaml',
|
|
- borgmatic.hooks.monitor.State.FAIL,
|
|
|
|
|
|
+ borgmatic.hooks.monitoring.monitor.State.FAIL,
|
|
monitoring_log_level=1,
|
|
monitoring_log_level=1,
|
|
dry_run=True,
|
|
dry_run=True,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_notifies_fail_by_default():
|
|
def test_ping_monitor_notifies_fail_by_default():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler')
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler')
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
'format_buffered_logs_for_payload'
|
|
'format_buffered_logs_for_payload'
|
|
).and_return('')
|
|
).and_return('')
|
|
mock_apprise().should_receive('notify').with_args(
|
|
mock_apprise().should_receive('notify').with_args(
|
|
@@ -109,7 +115,7 @@ def test_ping_monitor_notifies_fail_by_default():
|
|
notify_type=NotifyType.FAILURE,
|
|
notify_type=NotifyType.FAILURE,
|
|
).once()
|
|
).once()
|
|
|
|
|
|
- for state in borgmatic.hooks.monitor.State:
|
|
|
|
|
|
+ for state in borgmatic.hooks.monitoring.monitor.State:
|
|
module.ping_monitor(
|
|
module.ping_monitor(
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}]},
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}]},
|
|
{},
|
|
{},
|
|
@@ -121,8 +127,8 @@ def test_ping_monitor_notifies_fail_by_default():
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_with_logs_appends_logs_to_body():
|
|
def test_ping_monitor_with_logs_appends_logs_to_body():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler')
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler')
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
'format_buffered_logs_for_payload'
|
|
'format_buffered_logs_for_payload'
|
|
).and_return('loggy log')
|
|
).and_return('loggy log')
|
|
mock_apprise().should_receive('notify').with_args(
|
|
mock_apprise().should_receive('notify').with_args(
|
|
@@ -132,7 +138,7 @@ def test_ping_monitor_with_logs_appends_logs_to_body():
|
|
notify_type=NotifyType.FAILURE,
|
|
notify_type=NotifyType.FAILURE,
|
|
).once()
|
|
).once()
|
|
|
|
|
|
- for state in borgmatic.hooks.monitor.State:
|
|
|
|
|
|
+ for state in borgmatic.hooks.monitoring.monitor.State:
|
|
module.ping_monitor(
|
|
module.ping_monitor(
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}]},
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}]},
|
|
{},
|
|
{},
|
|
@@ -144,8 +150,8 @@ def test_ping_monitor_with_logs_appends_logs_to_body():
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_with_finish_default_config_notifies():
|
|
def test_ping_monitor_with_finish_default_config_notifies():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler')
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler')
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
'format_buffered_logs_for_payload'
|
|
'format_buffered_logs_for_payload'
|
|
).and_return('')
|
|
).and_return('')
|
|
mock_apprise().should_receive('notify').with_args(
|
|
mock_apprise().should_receive('notify').with_args(
|
|
@@ -159,15 +165,17 @@ def test_ping_monitor_with_finish_default_config_notifies():
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}], 'states': ['finish']},
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}], 'states': ['finish']},
|
|
{},
|
|
{},
|
|
'config.yaml',
|
|
'config.yaml',
|
|
- borgmatic.hooks.monitor.State.FINISH,
|
|
|
|
|
|
+ borgmatic.hooks.monitoring.monitor.State.FINISH,
|
|
monitoring_log_level=1,
|
|
monitoring_log_level=1,
|
|
dry_run=False,
|
|
dry_run=False,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_with_start_default_config_notifies():
|
|
def test_ping_monitor_with_start_default_config_notifies():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler').never()
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('format_buffered_logs_for_payload').never()
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler').never()
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
|
|
+ 'format_buffered_logs_for_payload'
|
|
|
|
+ ).never()
|
|
mock_apprise().should_receive('notify').with_args(
|
|
mock_apprise().should_receive('notify').with_args(
|
|
title='A borgmatic START event happened',
|
|
title='A borgmatic START event happened',
|
|
body='A borgmatic START event happened',
|
|
body='A borgmatic START event happened',
|
|
@@ -179,15 +187,15 @@ def test_ping_monitor_with_start_default_config_notifies():
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}], 'states': ['start']},
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}], 'states': ['start']},
|
|
{},
|
|
{},
|
|
'config.yaml',
|
|
'config.yaml',
|
|
- borgmatic.hooks.monitor.State.START,
|
|
|
|
|
|
+ borgmatic.hooks.monitoring.monitor.State.START,
|
|
monitoring_log_level=1,
|
|
monitoring_log_level=1,
|
|
dry_run=False,
|
|
dry_run=False,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_with_fail_default_config_notifies():
|
|
def test_ping_monitor_with_fail_default_config_notifies():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler')
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler')
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
'format_buffered_logs_for_payload'
|
|
'format_buffered_logs_for_payload'
|
|
).and_return('')
|
|
).and_return('')
|
|
mock_apprise().should_receive('notify').with_args(
|
|
mock_apprise().should_receive('notify').with_args(
|
|
@@ -201,15 +209,15 @@ def test_ping_monitor_with_fail_default_config_notifies():
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}], 'states': ['fail']},
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}], 'states': ['fail']},
|
|
{},
|
|
{},
|
|
'config.yaml',
|
|
'config.yaml',
|
|
- borgmatic.hooks.monitor.State.FAIL,
|
|
|
|
|
|
+ borgmatic.hooks.monitoring.monitor.State.FAIL,
|
|
monitoring_log_level=1,
|
|
monitoring_log_level=1,
|
|
dry_run=False,
|
|
dry_run=False,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_with_log_default_config_notifies():
|
|
def test_ping_monitor_with_log_default_config_notifies():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler')
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler')
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
'format_buffered_logs_for_payload'
|
|
'format_buffered_logs_for_payload'
|
|
).and_return('')
|
|
).and_return('')
|
|
mock_apprise().should_receive('notify').with_args(
|
|
mock_apprise().should_receive('notify').with_args(
|
|
@@ -223,15 +231,15 @@ def test_ping_monitor_with_log_default_config_notifies():
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}], 'states': ['log']},
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}], 'states': ['log']},
|
|
{},
|
|
{},
|
|
'config.yaml',
|
|
'config.yaml',
|
|
- borgmatic.hooks.monitor.State.LOG,
|
|
|
|
|
|
+ borgmatic.hooks.monitoring.monitor.State.LOG,
|
|
monitoring_log_level=1,
|
|
monitoring_log_level=1,
|
|
dry_run=False,
|
|
dry_run=False,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_passes_through_custom_message_title():
|
|
def test_ping_monitor_passes_through_custom_message_title():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler')
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler')
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
'format_buffered_logs_for_payload'
|
|
'format_buffered_logs_for_payload'
|
|
).and_return('')
|
|
).and_return('')
|
|
mock_apprise().should_receive('notify').with_args(
|
|
mock_apprise().should_receive('notify').with_args(
|
|
@@ -249,15 +257,15 @@ def test_ping_monitor_passes_through_custom_message_title():
|
|
},
|
|
},
|
|
{},
|
|
{},
|
|
'config.yaml',
|
|
'config.yaml',
|
|
- borgmatic.hooks.monitor.State.FAIL,
|
|
|
|
|
|
+ borgmatic.hooks.monitoring.monitor.State.FAIL,
|
|
monitoring_log_level=1,
|
|
monitoring_log_level=1,
|
|
dry_run=False,
|
|
dry_run=False,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_passes_through_custom_message_body():
|
|
def test_ping_monitor_passes_through_custom_message_body():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler')
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler')
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
'format_buffered_logs_for_payload'
|
|
'format_buffered_logs_for_payload'
|
|
).and_return('')
|
|
).and_return('')
|
|
mock_apprise().should_receive('notify').with_args(
|
|
mock_apprise().should_receive('notify').with_args(
|
|
@@ -275,15 +283,15 @@ def test_ping_monitor_passes_through_custom_message_body():
|
|
},
|
|
},
|
|
{},
|
|
{},
|
|
'config.yaml',
|
|
'config.yaml',
|
|
- borgmatic.hooks.monitor.State.FAIL,
|
|
|
|
|
|
+ borgmatic.hooks.monitoring.monitor.State.FAIL,
|
|
monitoring_log_level=1,
|
|
monitoring_log_level=1,
|
|
dry_run=False,
|
|
dry_run=False,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_passes_through_custom_message_body_and_appends_logs():
|
|
def test_ping_monitor_passes_through_custom_message_body_and_appends_logs():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler')
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler')
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
'format_buffered_logs_for_payload'
|
|
'format_buffered_logs_for_payload'
|
|
).and_return('loggy log')
|
|
).and_return('loggy log')
|
|
mock_apprise().should_receive('notify').with_args(
|
|
mock_apprise().should_receive('notify').with_args(
|
|
@@ -301,15 +309,15 @@ def test_ping_monitor_passes_through_custom_message_body_and_appends_logs():
|
|
},
|
|
},
|
|
{},
|
|
{},
|
|
'config.yaml',
|
|
'config.yaml',
|
|
- borgmatic.hooks.monitor.State.FAIL,
|
|
|
|
|
|
+ borgmatic.hooks.monitoring.monitor.State.FAIL,
|
|
monitoring_log_level=1,
|
|
monitoring_log_level=1,
|
|
dry_run=False,
|
|
dry_run=False,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_pings_multiple_services():
|
|
def test_ping_monitor_pings_multiple_services():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler')
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler')
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
'format_buffered_logs_for_payload'
|
|
'format_buffered_logs_for_payload'
|
|
).and_return('')
|
|
).and_return('')
|
|
mock_apprise().should_receive('add').with_args([f'ntfys://{TOPIC}', f'ntfy://{TOPIC}']).once()
|
|
mock_apprise().should_receive('add').with_args([f'ntfys://{TOPIC}', f'ntfy://{TOPIC}']).once()
|
|
@@ -323,36 +331,38 @@ def test_ping_monitor_pings_multiple_services():
|
|
},
|
|
},
|
|
{},
|
|
{},
|
|
'config.yaml',
|
|
'config.yaml',
|
|
- borgmatic.hooks.monitor.State.FAIL,
|
|
|
|
|
|
+ borgmatic.hooks.monitoring.monitor.State.FAIL,
|
|
monitoring_log_level=1,
|
|
monitoring_log_level=1,
|
|
dry_run=False,
|
|
dry_run=False,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_logs_info_for_no_services():
|
|
def test_ping_monitor_logs_info_for_no_services():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler').never()
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('format_buffered_logs_for_payload').never()
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler').never()
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
|
|
+ 'format_buffered_logs_for_payload'
|
|
|
|
+ ).never()
|
|
flexmock(module.logger).should_receive('info').once()
|
|
flexmock(module.logger).should_receive('info').once()
|
|
|
|
|
|
module.ping_monitor(
|
|
module.ping_monitor(
|
|
{'services': []},
|
|
{'services': []},
|
|
{},
|
|
{},
|
|
'config.yaml',
|
|
'config.yaml',
|
|
- borgmatic.hooks.monitor.State.FAIL,
|
|
|
|
|
|
+ borgmatic.hooks.monitoring.monitor.State.FAIL,
|
|
monitoring_log_level=1,
|
|
monitoring_log_level=1,
|
|
dry_run=False,
|
|
dry_run=False,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_ping_monitor_logs_warning_when_notify_fails():
|
|
def test_ping_monitor_logs_warning_when_notify_fails():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('get_handler')
|
|
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive(
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('get_handler')
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive(
|
|
'format_buffered_logs_for_payload'
|
|
'format_buffered_logs_for_payload'
|
|
).and_return('')
|
|
).and_return('')
|
|
mock_apprise().should_receive('notify').and_return(False)
|
|
mock_apprise().should_receive('notify').and_return(False)
|
|
flexmock(module.logger).should_receive('warning').once()
|
|
flexmock(module.logger).should_receive('warning').once()
|
|
|
|
|
|
- for state in borgmatic.hooks.monitor.State:
|
|
|
|
|
|
+ for state in borgmatic.hooks.monitoring.monitor.State:
|
|
module.ping_monitor(
|
|
module.ping_monitor(
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}]},
|
|
{'services': [{'url': f'ntfys://{TOPIC}', 'label': 'ntfys'}]},
|
|
{},
|
|
{},
|
|
@@ -364,7 +374,7 @@ def test_ping_monitor_logs_warning_when_notify_fails():
|
|
|
|
|
|
|
|
|
|
def test_destroy_monitor_does_not_raise():
|
|
def test_destroy_monitor_does_not_raise():
|
|
- flexmock(module.borgmatic.hooks.logs).should_receive('remove_handler')
|
|
|
|
|
|
+ flexmock(module.borgmatic.hooks.monitoring.logs).should_receive('remove_handler')
|
|
|
|
|
|
module.destroy_monitor(
|
|
module.destroy_monitor(
|
|
hook_config={},
|
|
hook_config={},
|