# 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/jira_notifier.py
# CONF = cfg.CONF
# class JiraNotifier(AbstractNotifier):
#     def __init__(self, log):
#     def config(self, config_dict):
#     def statsd_name(self):
#     def _get_jira_custom_format_fields(self):
#     def _build_custom_jira_message(self, notification, jira_fields_format):
#     def _build_default_jira_message(self, notification):
#     def _build_jira_message(self, notification):
#     def send_notification(self, notification):
#     def jira_workflow(self, jira_fields, jira_obj, notification):
# def register_opts(conf):
# def list_opts():
# 
# 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):


from unittest import mock
from monasca_notification import notification as m_notification
from monasca_notification.plugins import jira_notifier
from tests import base
import queue
def alarm():
    return {'tenantId': '0',
            'alarmId': '0',
            'alarmDefinitionId': 0,
            'alarmName': 'test Alarm',
            'alarmDescription': 'test Alarm description',
            'oldState': 'OK',
            'newState': 'ALARM',
            'severity': 'CRITICAL',
            'link': 'some-link',
            'lifecycleState': 'OPEN',
            'stateChangeReason': 'I am alarming!',
            'timestamp': 1429023453632,
            'metrics': {'dimension': {'hostname': 'foo1', 'service': 'bar1'}}}


def issue(component=True, custom_config=False):

    issue = {'fields': {'description': 'Monasca alarm',
                        'issuetype': {'name': 'Bug'},
                        'project': {'key': 'MyProject'},
                        'summary': 'Monasca alarm for alarm_defintion test Alarm status '
                                   'changed to ALARM for the alarm_id 0'}}
    if component:
        issue['fields'].update({'components': [{'name': 'MyComponent'}]})
    if custom_config:
        alarm_value = alarm()
        issue['fields'].update({'description': alarm_value.get('alarmName')})
        summary_format_string = 'Alarm created for {0} with severity {1} for {2}'
        summary = summary_format_string.format(alarm_value.get('alarmName'),

# 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/jira_notifier.py
# CONF = cfg.CONF
# class JiraNotifier(AbstractNotifier):
#     def __init__(self, log):
#     def config(self, config_dict):
#     def statsd_name(self):
#     def _get_jira_custom_format_fields(self):
#     def _build_custom_jira_message(self, notification, jira_fields_format):
#     def _build_default_jira_message(self, notification):
#     def _build_jira_message(self, notification):
#     def send_notification(self, notification):
#     def jira_workflow(self, jira_fields, jira_obj, notification):
# def register_opts(conf):
# def list_opts():
# 
# 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_jira_notification.py
from unittest import mock
from monasca_notification import notification as m_notification
from monasca_notification.plugins import jira_notifier
from tests import base
import queue

def alarm():
    return {'tenantId': '0',
            'alarmId': '0',
            'alarmDefinitionId': 0,
            'alarmName': 'test Alarm',
            'alarmDescription': 'test Alarm description',
            'oldState': 'OK',
            'newState': 'ALARM',
            'severity': 'CRITICAL',
            'link': 'some-link',
            'lifecycleState': 'OPEN',
            'stateChangeReason': 'I am alarming!',
            'timestamp': 1429023453632,
            'metrics': {'dimension': {'hostname': 'foo1', 'service': 'bar1'}}}


def issue(component=True, custom_config=False):

    issue = {'fields': {'description': 'Monasca alarm',
                        'issuetype': {'name': 'Bug'},
                        'project': {'key': 'MyProject'},
                        'summary': 'Monasca alarm for alarm_defintion test Alarm status '
                                   'changed to ALARM for the alarm_id 0'}}
    if component:
        issue['fields'].update({'components': [{'name': 'MyComponent'}]})
    if custom_config:
        alarm_value = alarm()
        issue['fields'].update({'description': alarm_value.get('alarmName')})
        summary_format_string = 'Alarm created for {0} with severity {1} for {2}'
        summary = summary_format_string.format(alarm_value.get('alarmName'),

                                               alarm_value.get('newState'),