# HG changeset patch # User Ludovic Chabant # Date 1514409953 28800 # Node ID c2cd2ac289b2c230665b6e63b181865d4967b491 # Parent 41f4f8dfa42dd61f4d6ecea871b134fabf15c11f tests: Add plugin tests. diff -r 41f4f8dfa42d -r c2cd2ac289b2 tests/test_plugins_base.py --- /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