def test_trigger_message_text(self): """ Test that Alerts are triggered with a text string """ # GIVEN: A valid Alert Manager alert_manager = AlertsManager(None) alert_manager.display_alert = MagicMock() # WHEN: Called with an empty string alert_manager.alert_text(['This is a string']) # THEN: the display should have been triggered assert alert_manager.display_alert.called is True, 'The Alert should have been called'
def test_remove_message_text(self): """ Test that Alerts are not triggered with empty strings """ # GIVEN: A valid Alert Manager alert_manager = AlertsManager(None) alert_manager.display_alert = MagicMock() # WHEN: Called with an empty string alert_manager.alert_text('') # THEN: the display should not have been triggered assert alert_manager.display_alert.called is False, 'The Alert should not have been called'
def test_trigger_message_text(self): """ Test that Alerts are triggered with a text string """ # GIVEN: A valid Alert Manager alert_manager = AlertsManager(None) alert_manager.display_alert = MagicMock() # WHEN: Called with an empty string alert_manager.alert_text(['This is a string']) # THEN: the display should have been triggered self.assertTrue(alert_manager.display_alert.called, 'The Alert should have been called')
def test_remove_message_text(self): """ Test that Alerts are not triggered with empty strings """ # GIVEN: A valid Alert Manager alert_manager = AlertsManager(None) alert_manager.display_alert = MagicMock() # WHEN: Called with an empty string alert_manager.alert_text('') # THEN: the display should not have been triggered self.assertFalse(alert_manager.display_alert.called, 'The Alert should not have been called')
def test_line_break_message_text(self): """ Test that Alerts are triggered with a text string but line breaks are removed """ # GIVEN: A valid Alert Manager alert_manager = AlertsManager(None) alert_manager.display_alert = MagicMock() # WHEN: Called with an empty string alert_manager.alert_text(['This is \n a string']) # THEN: the display should have been triggered assert alert_manager.display_alert.called is True, 'The Alert should have been called' alert_manager.display_alert.assert_called_once_with('This is a string')
def __init__(self): """ Class __init__ method """ super(AlertsPlugin, self).__init__('alerts', settings_tab_class=AlertsTab) self.weight = -3 self.icon_path = UiIcons().alert self.icon = self.icon_path AlertsManager(self) self.manager = Manager('alerts', init_schema) self.alert_form = AlertForm(self) register_endpoint(alerts_endpoint) register_endpoint(api_alerts_endpoint) State().add_service(self.name, self.weight, is_plugin=True) State().update_pre_conditions(self.name, self.check_pre_conditions())