From 98e429594e33cadf39579b3d271be0b2efb0ccb9 Mon Sep 17 00:00:00 2001 From: Soumik Dutta Date: Mon, 6 Mar 2023 20:31:00 +0530 Subject: [PATCH] added tests to make sure unsupported log states are detected Signed-off-by: Soumik Dutta --- tests/unit/hooks/test_cronhub.py | 10 ++++++++++ tests/unit/hooks/test_cronitor.py | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/unit/hooks/test_cronhub.py b/tests/unit/hooks/test_cronhub.py index 14e8eb2..9007d2c 100644 --- a/tests/unit/hooks/test_cronhub.py +++ b/tests/unit/hooks/test_cronhub.py @@ -102,3 +102,13 @@ def test_ping_monitor_with_other_error_logs_warning(): monitoring_log_level=1, dry_run=False, ) + + +def test_ping_monitor_with_unsupported_monitoring_state(): + hook_config = {'ping_url': 'https://example.com'} + flexmock(module.logger).should_receive("debug").once().with_args( + '{}: Ignoring unsupported monitoring {} in Cronhub hook'.format("config.yaml", "log") + ) + module.ping_monitor( + hook_config, 'config.yaml', module.monitor.State.LOG, monitoring_log_level=1, dry_run=False, + ) diff --git a/tests/unit/hooks/test_cronitor.py b/tests/unit/hooks/test_cronitor.py index 4b762d8..51fba98 100644 --- a/tests/unit/hooks/test_cronitor.py +++ b/tests/unit/hooks/test_cronitor.py @@ -87,3 +87,13 @@ def test_ping_monitor_with_other_error_logs_warning(): monitoring_log_level=1, dry_run=False, ) + + +def test_ping_monitor_with_unsupported_monitoring_state(): + hook_config = {'ping_url': 'https://example.com'} + flexmock(module.logger).should_receive("debug").once().with_args( + '{}: Ignoring unsupported monitoring {} in Cronitor hook'.format("config.yaml", "log") + ) + module.ping_monitor( + hook_config, 'config.yaml', module.monitor.State.LOG, monitoring_log_level=1, dry_run=False, + )