annotate tests/test_plugins_base.py @ 1145:e94737572542

serve: Fix an issue where false positive matches were rendered as the requested page. Now we try to render the page, but also try to detect for the most common "empty" pages.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 05 Jun 2018 22:08:51 -0700
parents c1e062843464
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1030
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
1 from .mockutil import mock_fs, mock_fs_scope
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 def test_no_plugins():
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5 fs = (mock_fs()
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6 .withConfig())
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7 with mock_fs_scope(fs):
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
8 app = fs.getApp()
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9 assert len(app.plugin_loader.plugins) == 1
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10 assert app.plugin_loader.plugins[0].name == '__builtin__'
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13 testplug_code = """from piecrust.plugins.base import PieCrustPlugin
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
14
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
15 class TestPlugPlugin(PieCrustPlugin):
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16 name = 'just a test plugin'
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
18 __piecrust_plugin__ = TestPlugPlugin
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19 """
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
20
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21 def test_loose_file():
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
22 fs = (mock_fs()
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
23 .withConfig({'site': {'plugins': 'testplug'}})
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24 .withFile('kitchen/plugins/testplug.py', testplug_code))
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25 with mock_fs_scope(fs):
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
26 app = fs.getApp()
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
27 assert sorted([p.name for p in app.plugin_loader.plugins]) == \
c2cd2ac289b2 tests: Add plugin tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
28 sorted(['__builtin__', 'just a test plugin'])