annotate tests/test_plugins_base.py @ 1051:971b4d67e82a

serve: Fix problems with assets disappearing between servings. When an asset file changes, its source's pipeline is re-run. But that created a bake record that only had that pipeline's output, so the other outputs were incorrectly considered empty and therefore any stray files were removed. Now we copy over bake records for the pipelines we don't run.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 26 Jan 2018 18:05:02 -0800
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'])