# Path: monasca_notification/notification.py
# class Notification(object):
#     def __init__(self, id, type, name, address, period, retry_count, alarm):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def to_json(self):
# 
# Path: monasca_notification/plugins/email_notifier.py
# CONF = cfg.CONF
# EMAIL_SINGLE_HOST_BASE = u'''On host "{hostname}" for target "{target_host}" {message}
# 
# Alarm "{alarm_name}" transitioned to the {state} state at {timestamp} UTC
# alarm_id: {alarm_id}
# 
# Lifecycle state: {lifecycle_state}
# Link: {link}
# Link to Grafana: {grafana_url}
# 
# With dimensions:
# {metric_dimensions}'''
# EMAIL_MULTIPLE_HOST_BASE = u'''On host "{hostname}" {message}
# 
# Alarm "{alarm_name}" transitioned to the {state} state at {timestamp} UTC
# alarm_id: {alarm_id}
# 
# Lifecycle state: {lifecycle_state}
# Link: {link}
# Link to Grafana: {grafana_url}
# 
# With dimensions:
# {metric_dimensions}'''
# EMAIL_NO_HOST_BASE = u'''On multiple hosts {message}
# 
# Alarm "{alarm_name}" transitioned to the {state} state at {timestamp} UTC
# Alarm_id: {alarm_id}
# 
# Lifecycle state: {lifecycle_state}
# Link: {link}
# Link to Grafana: {grafana_url}
# 
# With dimensions
# {metric_dimensions}'''
# class EmailNotifier(abstract_notifier.AbstractNotifier):
#     def __init__(self, log):
#     def config(self, config=None):
#     def statsd_name(self):
#     def send_notification(self, notification):
#     def _sendmail(self, notification, msg):
#     def _email_error(self, notification):
#     def _smtp_connect(self):
#     def _create_msg(self, hostname, notification, targethost=None):
#     def _get_link_url(self, metric, timestamp_ms):
# def _format_dimensions(notification):
# def register_opts(conf):
# def list_opts():
# 
# Path: monasca_notification/processors/notification_processor.py
# class NotificationProcessor(object):
#     def __init__(self):
#     def _remaining_plugin_types(self):
#     def insert_configured_plugins(self):
#     def send(self, notifications):
# 
# Path: tests/base.py
# class DisableStatsdFixture(fixtures.Fixture):
# class ConfigFixture(oo_cfg.Config):
# class BaseTestCase(oslotest_base.BaseTestCase):
# class PluginTestCase(BaseTestCase):
#     def setUp(self):
#     def __init__(self):
#     def setUp(self):
#     def _clean_config_loaded_flag():
#     def setUp(self):
#     def conf_override(**kw):
#     def conf_default(**kw):
#     def setUp(self, register_opts=None):


import time
from unittest import mock
from monasca_notification import notification as m_notification
from monasca_notification.plugins import email_notifier
from monasca_notification.processors import notification_processor as np
from tests import base
                      "link": "some-link",
                      "lifecycleState": "OPEN",
                      "stateChangeReason": "I am alarming!",
                      "timestamp": time.time(),
                      "metrics": metric}

        notification = m_notification.Notification(
            0, 'email', 'email notification', 'me@here.com', 0, 0, alarm_dict)

        self._start_processor([notification])

    # ------------------------------------------------------------------------
    # Unit tests
    # ------------------------------------------------------------------------

    def test_invalid_notification(self):
        """Verify invalid notification type is rejected.
        """
        alarm_dict = {
            "tenantId": "0",
            "alarmId": "0",
            "alarmName": "test Alarm",
            "oldState": "OK",
            "newState": "ALARM",
            "stateChangeReason": "I am alarming!",
            "timestamp": time.time(),
            "metrics": "cpu_util",
            "severity": "LOW",
            "link": "http://some-place.com",
            "lifecycleState": "OPEN"}

# Path: monasca_notification/notification.py
# class Notification(object):
#     def __init__(self, id, type, name, address, period, retry_count, alarm):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def to_json(self):
# 
# Path: monasca_notification/plugins/email_notifier.py
# CONF = cfg.CONF
# EMAIL_SINGLE_HOST_BASE = u'''On host "{hostname}" for target "{target_host}" {message}
# 
# Alarm "{alarm_name}" transitioned to the {state} state at {timestamp} UTC
# alarm_id: {alarm_id}
# 
# Lifecycle state: {lifecycle_state}
# Link: {link}
# Link to Grafana: {grafana_url}
# 
# With dimensions:
# {metric_dimensions}'''
# EMAIL_MULTIPLE_HOST_BASE = u'''On host "{hostname}" {message}
# 
# Alarm "{alarm_name}" transitioned to the {state} state at {timestamp} UTC
# alarm_id: {alarm_id}
# 
# Lifecycle state: {lifecycle_state}
# Link: {link}
# Link to Grafana: {grafana_url}
# 
# With dimensions:
# {metric_dimensions}'''
# EMAIL_NO_HOST_BASE = u'''On multiple hosts {message}
# 
# Alarm "{alarm_name}" transitioned to the {state} state at {timestamp} UTC
# Alarm_id: {alarm_id}
# 
# Lifecycle state: {lifecycle_state}
# Link: {link}
# Link to Grafana: {grafana_url}
# 
# With dimensions
# {metric_dimensions}'''
# class EmailNotifier(abstract_notifier.AbstractNotifier):
#     def __init__(self, log):
#     def config(self, config=None):
#     def statsd_name(self):
#     def send_notification(self, notification):
#     def _sendmail(self, notification, msg):
#     def _email_error(self, notification):
#     def _smtp_connect(self):
#     def _create_msg(self, hostname, notification, targethost=None):
#     def _get_link_url(self, metric, timestamp_ms):
# def _format_dimensions(notification):
# def register_opts(conf):
# def list_opts():
# 
# Path: monasca_notification/processors/notification_processor.py
# class NotificationProcessor(object):
#     def __init__(self):
#     def _remaining_plugin_types(self):
#     def insert_configured_plugins(self):
#     def send(self, notifications):
# 
# Path: tests/base.py
# class DisableStatsdFixture(fixtures.Fixture):
# class ConfigFixture(oo_cfg.Config):
# class BaseTestCase(oslotest_base.BaseTestCase):
# class PluginTestCase(BaseTestCase):
#     def setUp(self):
#     def __init__(self):
#     def setUp(self):
#     def _clean_config_loaded_flag():
#     def setUp(self):
#     def conf_override(**kw):
#     def conf_default(**kw):
#     def setUp(self, register_opts=None):


# Path: tests/test_notification_processor.py
import time
from unittest import mock
from monasca_notification import notification as m_notification
from monasca_notification.plugins import email_notifier
from monasca_notification.processors import notification_processor as np
from tests import base

                      "link": "some-link",
                      "lifecycleState": "OPEN",
                      "stateChangeReason": "I am alarming!",
                      "timestamp": time.time(),
                      "metrics": metric}

        notification = m_notification.Notification(
            0, 'email', 'email notification', 'me@here.com', 0, 0, alarm_dict)

        self._start_processor([notification])

    # ------------------------------------------------------------------------
    # Unit tests
    # ------------------------------------------------------------------------

    def test_invalid_notification(self):
        """Verify invalid notification type is rejected.
        """
        alarm_dict = {
            "tenantId": "0",
            "alarmId": "0",
            "alarmName": "test Alarm",
            "oldState": "OK",
            "newState": "ALARM",
            "stateChangeReason": "I am alarming!",
            "timestamp": time.time(),
            "metrics": "cpu_util",
            "severity": "LOW",
            "link": "http://some-place.com",
            "lifecycleState": "OPEN"}

        invalid_notification = m_notification.Notification(0, 'invalid', 'test notification',