# Path: canaryd/diff.py
# class Change(object):
#     def __init__(self, plugin, type_, key, data=None):
#         self.plugin = plugin
#         self.type = type_
#         self.key = key
# 
#         # COMPAT w/canaryd < 0.2
#         # Legacy support where added/deleted would either have data/None,
#         # rather than data changes (where every key: (old_value, new_value)).
#         if data and self.type in ('added', 'deleted') and not all(
#             isinstance(item, (tuple, list)) and len(item) == 2
#             for _, item in six.iteritems(data)
#         ):
#             if self.type == 'added':
#                 data = dict(
#                     (key, (None, value))
#                     for key, value in six.iteritems(data)
#                 )
# 
#             elif self.type == 'deleted':
#                 data = dict(
#                     (key, (value, None))
#                     for key, value in six.iteritems(data)
#                 )
# 
#             logger.info('Converted legacy data: {0}'.format(data))
# 
#         self.data = data
# 
#     def serialise(self):
#         return self.type, self.key, self.data
# 
#     def __repr__(self):
#         return 'Change: {0}'.format((self.plugin, self.type, self.key, self.data))
# 
# Path: canaryd/plugin.py
# def get_plugin_by_name(plugin_name):
#     if plugin_name not in NAME_TO_PLUGIN:
#         raise NoPluginError('Missing plugin: {0}'.format(plugin_name))
# 
#     return NAME_TO_PLUGIN[plugin_name]
# 
# def get_plugins():
#     '''
#     Get the list of installed plugins.
#     '''
# 
#     return PLUGINS


from unittest import TestCase
from canaryd.diff import Change
from canaryd.plugin import get_plugin_by_name, get_plugins
        action = self.plugin.get_action_for_change(change)
        self.assertEqual(action, 'restarted')

    def test_generate_resolved_issue(self):
        change = Change(self.plugin, 'deleted', 'key')

        issues = list(self.plugin.generate_issues_from_change(change, {}))

        self.assertEqual(len(issues), 1)
        self.assertEqual(issues[0], ('resolved', None, None))


class TestMonitorEvents(TestCase):
    def setUp(self):
        self.plugin = get_plugin_by_name('monitor')

    def test_generate_resolved_issue(self):
        change = Change(self.plugin, 'deleted', 'key')

        issues = list(self.plugin.generate_issues_from_change(change, {}))

        self.assertEqual(len(issues), 1)
        self.assertEqual(
            issues[0],
            ('resolved', 'key is back to normal', None),
        )


class TestScriptEvents(TestCase):
    def setUp(self):

# Path: canaryd/diff.py
# class Change(object):
#     def __init__(self, plugin, type_, key, data=None):
#         self.plugin = plugin
#         self.type = type_
#         self.key = key
# 
#         # COMPAT w/canaryd < 0.2
#         # Legacy support where added/deleted would either have data/None,
#         # rather than data changes (where every key: (old_value, new_value)).
#         if data and self.type in ('added', 'deleted') and not all(
#             isinstance(item, (tuple, list)) and len(item) == 2
#             for _, item in six.iteritems(data)
#         ):
#             if self.type == 'added':
#                 data = dict(
#                     (key, (None, value))
#                     for key, value in six.iteritems(data)
#                 )
# 
#             elif self.type == 'deleted':
#                 data = dict(
#                     (key, (value, None))
#                     for key, value in six.iteritems(data)
#                 )
# 
#             logger.info('Converted legacy data: {0}'.format(data))
# 
#         self.data = data
# 
#     def serialise(self):
#         return self.type, self.key, self.data
# 
#     def __repr__(self):
#         return 'Change: {0}'.format((self.plugin, self.type, self.key, self.data))
# 
# Path: canaryd/plugin.py
# def get_plugin_by_name(plugin_name):
#     if plugin_name not in NAME_TO_PLUGIN:
#         raise NoPluginError('Missing plugin: {0}'.format(plugin_name))
# 
#     return NAME_TO_PLUGIN[plugin_name]
# 
# def get_plugins():
#     '''
#     Get the list of installed plugins.
#     '''
# 
#     return PLUGINS


# Path: tests/test_plugin_events.py
from unittest import TestCase
from canaryd.diff import Change
from canaryd.plugin import get_plugin_by_name, get_plugins

        action = self.plugin.get_action_for_change(change)
        self.assertEqual(action, 'restarted')

    def test_generate_resolved_issue(self):
        change = Change(self.plugin, 'deleted', 'key')

        issues = list(self.plugin.generate_issues_from_change(change, {}))

        self.assertEqual(len(issues), 1)
        self.assertEqual(issues[0], ('resolved', None, None))


class TestMonitorEvents(TestCase):
    def setUp(self):
        self.plugin = get_plugin_by_name('monitor')

    def test_generate_resolved_issue(self):
        change = Change(self.plugin, 'deleted', 'key')

        issues = list(self.plugin.generate_issues_from_change(change, {}))

        self.assertEqual(len(issues), 1)
        self.assertEqual(
            issues[0],
            ('resolved', 'key is back to normal', None),
        )


class TestScriptEvents(TestCase):
    def setUp(self):

        self.plugin = get_plugin_by_name('scripts')