Skip to content

Commit

Permalink
Test that monitor attributes are synced as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneharter committed May 21, 2024
1 parent 9fde984 commit cf52488
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cronitor/tests/test_pings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -104,3 +114,4 @@ def staging_env_function_call(self):




0 comments on commit cf52488

Please sign in to comment.