Mercurial > piecrust2
comparison tests/test_server.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 |
comparison
equal
deleted
inserted
replaced
2:40fa08b261b9 | 3:f485ba500df3 |
---|---|
1 import re | |
2 import pytest | |
3 import mock | |
4 from piecrust.serving import find_routes | |
5 from piecrust.sources.base import REALM_USER, REALM_THEME | |
6 | |
7 | |
8 @pytest.mark.parametrize('uri, route_specs, expected', | |
9 [ | |
10 ('/', | |
11 [{'src': 'pages', 'pat': '(?P<path>.*)'}], | |
12 [('pages', {'path': ''})]), | |
13 ('/', | |
14 [{'src': 'pages', 'pat': '(?P<path>.*)'}, | |
15 {'src': 'theme', 'pat': '(?P<path>.*)', 'realm': REALM_THEME}], | |
16 [('pages', {'path': ''}), ('theme', {'path': ''})]) | |
17 ]) | |
18 def test_find_routes(uri, route_specs, expected): | |
19 routes = [] | |
20 for rs in route_specs: | |
21 m = mock.Mock() | |
22 m.source_name = rs['src'] | |
23 m.source_realm = rs.setdefault('realm', REALM_USER) | |
24 m.uri_re = re.compile(rs['pat']) | |
25 routes.append(m) | |
26 matching = find_routes(routes, uri) | |
27 | |
28 assert len(matching) == len(expected) | |
29 for i in range(len(matching)): | |
30 route, metadata = matching[i] | |
31 exp_source, exp_md = expected[i] | |
32 assert route.source_name == exp_source | |
33 assert metadata == exp_md | |
34 |