def test_notifies_subscribers_when_should(self): redash.tasks.alerts.notify_subscriptions = MagicMock() Alert.evaluate = MagicMock(return_value=Alert.TRIGGERED_STATE) alert = self.factory.create_alert() check_alerts_for_query(alert.query_id) self.assertTrue(redash.tasks.alerts.notify_subscriptions.called)
def test_doesnt_notify_when_nothing_changed(self): redash.tasks.alerts.notify_subscriptions = MagicMock() Alert.evaluate = MagicMock(return_value=Alert.OK_STATE) alert = self.factory.create_alert() check_alerts_for_query(alert.query_id) self.assertFalse(redash.tasks.alerts.notify_subscriptions.called)
def test_doesnt_notify_when_muted(self): redash.tasks.alerts.notify_subscriptions = MagicMock() Alert.evaluate = MagicMock(return_value=Alert.TRIGGERED_STATE) alert = self.factory.create_alert(options={"muted": True}) check_alerts_for_query(alert.query_id) self.assertFalse(redash.tasks.alerts.notify_subscriptions.called)