def test_enabled_notifications(self, mock_log, mock_smtp): notifiers.init(self.statsd) notifiers.config() notifications = notifiers.enabled_notifications() self.assertEqual(len(notifications), 3) self.assertEqual(sorted(notifications), ["EMAIL", "PAGERDUTY", "WEBHOOK"])
def test_enabled_notifications_none(self): self.conf_override(group='notification_types', enabled=[]) notifiers.init(self.statsd) notifiers.load_plugins() notifiers.config() notifications = notifiers.enabled_notifications() self.assertEqual(len(notifications), 0)
def test_enabled_notifications(self, mock_log, mock_smtp): config_dict = {'email': self.email_config, 'webhook': {'address': 'xyz.com'}, 'pagerduty': {'address': 'xyz.com'}} notifiers.init(self.statsd) notifiers.config(config_dict) notifications = notifiers.enabled_notifications() self.assertEqual(len(notifications), 3) self.assertEqual(sorted(notifications), ["EMAIL", "PAGERDUTY", "WEBHOOK"])
def test_enabled_notifications_none(self): self.conf_override( group='notification_types', enabled=[] ) notifiers.init(self.statsd) notifiers.load_plugins() notifiers.config() notifications = notifiers.enabled_notifications() self.assertEqual(len(notifications), 0)
def insert_configured_plugins(self): """Persists configured plugin types in DB For each notification type configured add it in db, if it is not there """ configured_plugin_types = notifiers.enabled_notifications() persisted_plugin_types = self._db_repo.fetch_notification_method_types() remaining_plugin_types = set(configured_plugin_types) - set(persisted_plugin_types) if remaining_plugin_types: log.info("New plugins detected: Adding new notification types {} to database" .format(remaining_plugin_types)) self._db_repo.insert_notification_method_types(remaining_plugin_types)
def insert_configured_plugins(self): """Persists configured plugin types in DB For each notification type configured add it in db, if it is not there """ configured_plugin_types = notifiers.enabled_notifications() persisted_plugin_types = self._db_repo.fetch_notification_method_types( ) remaining_plugin_types = set(configured_plugin_types) - set( persisted_plugin_types) if remaining_plugin_types: log.info( "New plugins detected: Adding new notification types {} to database" .format(remaining_plugin_types)) self._db_repo.insert_notification_method_types( remaining_plugin_types)
def test_enabled_notifications(self, mock_log, mock_smtp): config_dict = { 'email': self.email_config, 'webhook': { 'address': 'xyz.com' }, 'pagerduty': { 'address': 'xyz.com' } } notifiers.init(self.statsd) notifiers.config(config_dict) notifications = notifiers.enabled_notifications() self.assertEqual(len(notifications), 3) self.assertEqual(sorted(notifications), ["EMAIL", "PAGERDUTY", "WEBHOOK"])
def test_enabled_notifications(self): self.conf_override( group='notification_types', enabled=[ 'monasca_notification.plugins.email_notifier:EmailNotifier', 'monasca_notification.plugins.pagerduty_notifier:PagerdutyNotifier', 'monasca_notification.plugins.webhook_notifier:WebhookNotifier', 'monasca_notification.plugins.hipchat_notifier:HipChatNotifier', 'monasca_notification.plugins.slack_notifier:SlackNotifier', 'monasca_notification.plugins.jira_notifier:JiraNotifier' ]) notifiers.init(self.statsd) notifiers.load_plugins() notifiers.config() notifications = notifiers.enabled_notifications() self.assertEqual(len(notifications), 6) self.assertItemsEqual( notifications, ['EMAIL', 'PAGERDUTY', 'WEBHOOK', 'HIPCHAT', 'SLACK', 'JIRA'])
def test_enabled_notifications(self): self.conf_override( group='notification_types', enabled=[ 'monasca_notification.plugins.email_notifier:EmailNotifier', 'monasca_notification.plugins.pagerduty_notifier:PagerdutyNotifier', 'monasca_notification.plugins.webhook_notifier:WebhookNotifier', 'monasca_notification.plugins.hipchat_notifier:HipChatNotifier', 'monasca_notification.plugins.slack_notifier:SlackNotifier', 'monasca_notification.plugins.jira_notifier:JiraNotifier' ] ) notifiers.init(self.statsd) notifiers.load_plugins() notifiers.config() notifications = notifiers.enabled_notifications() self.assertEqual(len(notifications), 6) self.assertItemsEqual(notifications, ['EMAIL', 'PAGERDUTY', 'WEBHOOK', 'HIPCHAT', 'SLACK', 'JIRA'])
def _remaining_plugin_types(self): configured_plugin_types = notifiers.enabled_notifications() persisted_plugin_types = self._db_repo.fetch_notification_method_types( ) return set(configured_plugin_types) - set(persisted_plugin_types)
def _remaining_plugin_types(self): configured_plugin_types = notifiers.enabled_notifications() persisted_plugin_types = self._db_repo.fetch_notification_method_types() return set(configured_plugin_types) - set(persisted_plugin_types)