Mercurial > piecrust2
comparison tests/test_processing_tree.py @ 3:f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
- Serving works, with debug window.
- Baking works, multi-threading, with dependency handling.
- Various things not implemented yet.
| author | Ludovic Chabant <ludovic@chabant.com> |
|---|---|
| date | Sun, 10 Aug 2014 23:43:16 -0700 |
| parents | |
| children | 72f17534d58e |
comparison
equal
deleted
inserted
replaced
| 2:40fa08b261b9 | 3:f485ba500df3 |
|---|---|
| 1 from piecrust.processing.base import CopyFileProcessor, SimpleFileProcessor | |
| 2 from piecrust.processing.tree import ProcessingTreeBuilder, ProcessingTreeNode | |
| 3 | |
| 4 | |
| 5 class MockProcessor(SimpleFileProcessor): | |
| 6 def __init__(self): | |
| 7 super(MockProcessor, self).__init__({'mock': 'out'}) | |
| 8 self.processed = [] | |
| 9 | |
| 10 def _doProcess(self, in_path, out_path): | |
| 11 self.processed.append((in_path, out_path)) | |
| 12 | |
| 13 | |
| 14 mock_processors = [MockProcessor(), CopyFileProcessor()] | |
| 15 IDX_MOCK = 0 | |
| 16 IDX_COPY = 1 | |
| 17 | |
| 18 | |
| 19 def test_mock_node(): | |
| 20 node = ProcessingTreeNode('/foo.mock', list(mock_processors)) | |
| 21 assert node.getProcessor() == mock_processors[IDX_MOCK] | |
| 22 | |
| 23 | |
| 24 def test_copy_node(): | |
| 25 node = ProcessingTreeNode('/foo.other', list(mock_processors)) | |
| 26 assert node.getProcessor() == mock_processors[IDX_COPY] | |
| 27 | |
| 28 | |
| 29 def test_build_simple_tree(): | |
| 30 builder = ProcessingTreeBuilder(mock_processors) | |
| 31 root = builder.build('/foo.mock') | |
| 32 assert root is not None | |
| 33 assert root.getProcessor() == mock_processors[IDX_MOCK] | |
| 34 assert not root.is_leaf | |
| 35 assert len(root.outputs) == 1 | |
| 36 out = root.outputs[0] | |
| 37 assert out.getProcessor() == mock_processors[IDX_COPY] | |
| 38 |
