# 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/slack_notifier.py
# CONF = cfg.CONF
#     MAX_CACHE_SIZE = 100
#     RESPONSE_OK = 'ok'
# class SlackNotifier(abstract_notifier.AbstractNotifier):
#     def __init__(self, log):
#     def config(self, config_dict):
#     def statsd_name(self):
#     def _build_slack_message(self, notification):
#     def _render_message_template(self, params):
#     def _check_response(self, result):
#     def _send_message(self, request_options):
#     def send_notification(self, 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):


import json
import queue
from unittest import mock
from monasca_notification import notification as m_notification
from monasca_notification.plugins import slack_notifier
from tests import base
                         slack_notifier.SlackNotifier._raw_data_url_caches)

    def test_slack_post_message_success_cached(self):
        """url in cache and data is sent as raw data at first time
        """
        with mock.patch.object(slack_notifier.SlackNotifier,
                               '_raw_data_url_caches',
                               ['http://test.slack:3333']):
            response_list = [RequestsResponse(200, '{"ok":true}',
                                              {'Content-Type': 'application/json'})]
            mock_method, result = self._notify(response_list)
            self.assertTrue(result)
            mock_method.assert_called_once()
            self._validate_post_args(mock_method.call_args_list[0][1], 'data')
            self.assertEqual(['http://test.slack:3333'],
                             slack_notifier.SlackNotifier._raw_data_url_caches)

    def test_slack_post_message_failed_cached(self):
        """url in cache and slack returns failure
        """
        with mock.patch.object(slack_notifier.SlackNotifier,
                               '_raw_data_url_caches',
                               ['http://test.slack:3333']):
            response_list = [RequestsResponse(200, '{"ok":false,"error":"failure"}',
                                              {'Content-Type': 'application/json'})]
            mock_method, result = self._notify(response_list)
            self.assertFalse(result)
            mock_method.assert_called_once()
            self._validate_post_args(mock_method.call_args_list[0][1], 'data')
            self.assertEqual(['http://test.slack:3333'],

# 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/slack_notifier.py
# CONF = cfg.CONF
#     MAX_CACHE_SIZE = 100
#     RESPONSE_OK = 'ok'
# class SlackNotifier(abstract_notifier.AbstractNotifier):
#     def __init__(self, log):
#     def config(self, config_dict):
#     def statsd_name(self):
#     def _build_slack_message(self, notification):
#     def _render_message_template(self, params):
#     def _check_response(self, result):
#     def _send_message(self, request_options):
#     def send_notification(self, 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_slack_notification.py
import json
import queue
from unittest import mock
from monasca_notification import notification as m_notification
from monasca_notification.plugins import slack_notifier
from tests import base

                         slack_notifier.SlackNotifier._raw_data_url_caches)

    def test_slack_post_message_success_cached(self):
        """url in cache and data is sent as raw data at first time
        """
        with mock.patch.object(slack_notifier.SlackNotifier,
                               '_raw_data_url_caches',
                               ['http://test.slack:3333']):
            response_list = [RequestsResponse(200, '{"ok":true}',
                                              {'Content-Type': 'application/json'})]
            mock_method, result = self._notify(response_list)
            self.assertTrue(result)
            mock_method.assert_called_once()
            self._validate_post_args(mock_method.call_args_list[0][1], 'data')
            self.assertEqual(['http://test.slack:3333'],
                             slack_notifier.SlackNotifier._raw_data_url_caches)

    def test_slack_post_message_failed_cached(self):
        """url in cache and slack returns failure
        """
        with mock.patch.object(slack_notifier.SlackNotifier,
                               '_raw_data_url_caches',
                               ['http://test.slack:3333']):
            response_list = [RequestsResponse(200, '{"ok":false,"error":"failure"}',
                                              {'Content-Type': 'application/json'})]
            mock_method, result = self._notify(response_list)
            self.assertFalse(result)
            mock_method.assert_called_once()
            self._validate_post_args(mock_method.call_args_list[0][1], 'data')
            self.assertEqual(['http://test.slack:3333'],

                             slack_notifier.SlackNotifier._raw_data_url_caches)