1
# Copyright 2011 Canonical Ltd.
3
# This file is part of desktopcouch.
5
# desktopcouch is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU Lesser General Public License version 3
7
# as published by the Free Software Foundation.
9
# desktopcouch is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public License
15
# along with desktopcouch. If not, see <http://www.gnu.org/licenses/>.
16
"""Tests for the plug-ins loading."""
20
from desktopcouch.application import plugins
21
from unittest import TestCase
24
class TestLoadPlugins(TestCase):
25
"""Tests for loading plug-ins."""
27
def test_load_plugins(self):
28
"""Test that plug-ins are loaded correctly."""
29
# pylint: disable=W0201
30
old_paths = plugins.DESKTOPCOUCH_PLUGIN_PATHS
31
plugins.DESKTOPCOUCH_PLUGIN_PATHS = [os.path.join(
32
os.path.dirname(__file__))]
35
def _fake_import(name, *args, **kwargs):
36
"""Fake import to check that we get imported."""
37
modname = name.replace('.test_', '.tests.test_')
38
if modname == __name__:
39
self._imported = modname
40
old_import = __import__
41
__builtins__['__import__'] = _fake_import
42
plugins.load_plugins()
43
__builtins__['__import__'] = old_import
44
plugins.DESKTOPCOUCH_PLUGIN_PATHS = old_paths
45
self.assertEqual(self._imported, __name__)