changeset 1030:c2cd2ac289b2

tests: Add plugin tests.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 27 Dec 2017 13:25:53 -0800
parents 41f4f8dfa42d
children c1e062843464
files tests/test_plugins_base.py
diffstat 1 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_plugins_base.py	Wed Dec 27 13:25:53 2017 -0800
@@ -0,0 +1,29 @@
+from .mockutil import mock_fs, mock_fs_scope
+
+
+def test_no_plugins():
+    fs = (mock_fs()
+          .withConfig())
+    with mock_fs_scope(fs):
+        app = fs.getApp()
+        assert len(app.plugin_loader.plugins) == 1
+        assert app.plugin_loader.plugins[0].name == '__builtin__'
+
+
+testplug_code = """from piecrust.plugins.base import PieCrustPlugin
+
+class TestPlugPlugin(PieCrustPlugin):
+    name = 'just a test plugin'
+
+__piecrust_plugin__ = TestPlugPlugin
+"""
+
+def test_loose_file():
+    fs = (mock_fs()
+          .withConfig({'site': {'plugins': 'testplug'}})
+          .withFile('kitchen/plugins/testplug.py', testplug_code))
+    with mock_fs_scope(fs):
+        app = fs.getApp()
+        assert sorted([p.name for p in app.plugin_loader.plugins]) == \
+          sorted(['__builtin__', 'just a test plugin'])
+        assert False