def test_get_alert(self): cond = Condition('humidity', 'LESS_THAN', 10) alert = Alert('alert1', 'trigger1', [{ "current_value": 263.576, "condition": cond }], { "lon": 37, "lat": 53 }, 1481802090232) alert_two = copy.deepcopy(alert) alert_two.id = 'alert_two' alerts = [alert_two, alert ] # Second alert has to be 1st element to have full coverage instance = Trigger(1526809375, 1527809375, [cond], [geo.Point(13.6, 46.9)], alerts=alerts, alert_channels=None) self.assertEqual(alert, instance.get_alert('alert1')) # Trigger without alerts instance.alerts = [] self.assertIsNone(instance.get_alert(alert_id='alert1'))
def test_get_alert(self): cond = Condition('humidity', 'LESS_THAN', 10) alert = Alert('alert1', 'trigger1', [{ "current_value": 263.576, "condition": cond }], { "lon": 37, "lat": 53 }, 1481802090232) alerts = [alert] instance = Trigger(1526809375, 1527809375, [cond], [geo.Point(13.6, 46.9)], alerts=alerts, alert_channels=None) self.assertEqual(alert, instance.get_alert('alert1'))