From cf52488576a2bc91bfb2dec8170baeba8a243e6f Mon Sep 17 00:00:00 2001 From: Shane Harter Date: Tue, 21 May 2024 12:06:09 -0700 Subject: [PATCH] Test that monitor attributes are synced as expected --- cronitor/tests/test_pings.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cronitor/tests/test_pings.py b/cronitor/tests/test_pings.py index e9540d0..3aaf6b8 100644 --- a/cronitor/tests/test_pings.py +++ b/cronitor/tests/test_pings.py @@ -9,6 +9,8 @@ FAKE_KEY = 'd3x0c1' FAKE_API_KEY = 'ping-api-key' +cronitor.Monitor.put = patch('cronitor.Monitor.put') + class MonitorPingTests(unittest.TestCase): def setUp(self): @@ -83,6 +85,10 @@ def test_ping_wraps_function_raises_exception(self, mocked_ping): self.assertRaises(Exception, lambda: self.error_function_call()) mocked_ping.assert_has_calls(calls) + def test_monitor_attributes_are_put(self): + calls = [call([{'key': 'ping-decorator-test', 'name': 'Ping Decorator Test'}])] + cronitor.Monitor.put.assert_has_calls(calls) + @patch('cronitor.Monitor.ping') @patch('cronitor.Monitor.__init__') def test_ping_with_non_default_env(self, mocked_monitor, mocked_ping): @@ -94,6 +100,10 @@ def test_ping_with_non_default_env(self, mocked_monitor, mocked_ping): def function_call(self): return + @cronitor.job('ping-decorator-test', attributes={'name': 'Ping Decorator Test'}) + def function_call_with_attributes(self): + return + @cronitor.job('ping-decorator-test') def error_function_call(self): raise Exception @@ -104,3 +114,4 @@ def staging_env_function_call(self): +