# Path: googkit/lib/error.py
# class GoogkitError(Exception):
#     """Base class for error in Googkit."""
# 
#     def __init__(self, message):
#         """Creates a local error of googkit by the specified message.
#         """
#         self._message = message
# 
#     @property
#     def message(self):
#         return self._message
# 
#     def __str__(self):
#         return self.message


import unittest
import os
import googkit.lib.plugin
from googkit.compat.unittest import mock
from googkit.lib.error import GoogkitError
                '/dummy/plugins/dummy1',
                '/dummy/plugins/dummy1/__init__.py',
                '/dummy/plugins/dummy1/command.py',
                '/dummy/plugins/dummy2',
                '/dummy/plugins/dummy2/__init__.py',
                '/dummy/plugins/dummy2/command.py',
                '/dummy/plugins/__init__.py'
            ]]
            return os.path.abspath(path) in exists

        def stub_isdir(path):
            dirs = [os.path.abspath(path) for path in [
                '/dummy/plugins/dummy1',
                '/dummy/plugins/dummy2'
            ]]
            return os.path.abspath(path) in dirs

        mock_tree = mock.MagicMock()
        mock_module = StubPlugin()
        mock_module.register = mock.MagicMock()
        dummy_plugin_dir = os.path.normcase('/dummy/plugins')

        with mock.patch('os.listdir', return_value=['dummy1', 'dummy2']), \
                mock.patch('googkit.lib.path.plugin', return_value=dummy_plugin_dir), \
                mock.patch('os.path.exists', side_effect=stub_exists), \
                mock.patch('os.path.isdir', side_effect=stub_isdir), \
                mock.patch('googkit.lib.plugin.__import__', create=True, return_value=mock_module) as mock_import:
            googkit.lib.plugin.load(mock_tree)

        mock_import.assert_any_call('plugins.dummy1.command', fromlist=['command'])

# Path: googkit/lib/error.py
# class GoogkitError(Exception):
#     """Base class for error in Googkit."""
# 
#     def __init__(self, message):
#         """Creates a local error of googkit by the specified message.
#         """
#         self._message = message
# 
#     @property
#     def message(self):
#         return self._message
# 
#     def __str__(self):
#         return self.message


# Path: test/lib/test_plugin.py
import unittest
import os
import googkit.lib.plugin
from googkit.compat.unittest import mock
from googkit.lib.error import GoogkitError

                '/dummy/plugins/dummy1',
                '/dummy/plugins/dummy1/__init__.py',
                '/dummy/plugins/dummy1/command.py',
                '/dummy/plugins/dummy2',
                '/dummy/plugins/dummy2/__init__.py',
                '/dummy/plugins/dummy2/command.py',
                '/dummy/plugins/__init__.py'
            ]]
            return os.path.abspath(path) in exists

        def stub_isdir(path):
            dirs = [os.path.abspath(path) for path in [
                '/dummy/plugins/dummy1',
                '/dummy/plugins/dummy2'
            ]]
            return os.path.abspath(path) in dirs

        mock_tree = mock.MagicMock()
        mock_module = StubPlugin()
        mock_module.register = mock.MagicMock()
        dummy_plugin_dir = os.path.normcase('/dummy/plugins')

        with mock.patch('os.listdir', return_value=['dummy1', 'dummy2']), \
                mock.patch('googkit.lib.path.plugin', return_value=dummy_plugin_dir), \
                mock.patch('os.path.exists', side_effect=stub_exists), \
                mock.patch('os.path.isdir', side_effect=stub_isdir), \
                mock.patch('googkit.lib.plugin.__import__', create=True, return_value=mock_module) as mock_import:
            googkit.lib.plugin.load(mock_tree)

        mock_import.assert_any_call('plugins.dummy1.command', fromlist=['command'])

        mock_import.assert_any_call('plugins.dummy2.command', fromlist=['command'])