comparison tests/test_uriutil.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 474c9882decf
comparison
equal deleted inserted replaced
2:40fa08b261b9 3:f485ba500df3
1 import pytest
2 from piecrust.uriutil import UriInfo, parse_uri
3
4
5 @pytest.mark.parametrize('routes, uri, expected', [
6 ({}, '/foo', None),
7 (
8 {'/articles/%slug%': {'source': 'dummy'}},
9 '/articles/foo',
10 UriInfo('', 'dummy', {'slug': 'foo'})),
11 (
12 {'/foo/%bar%': {'source': 'foo'},
13 '/other/%one%-%two%': {'source': 'other'}},
14 '/other/some-thing',
15 UriInfo('', 'other', {'one': 'some', 'two': 'thing'}))
16 ])
17 def test_parse_uri(routes, uri, expected):
18 if expected is not None:
19 expected.uri = uri
20 for pattern, args in routes.iteritems():
21 if 'taxonomy' not in args:
22 args['taxonomy'] = None
23
24 actual = parse_uri(routes, uri)
25 assert actual == expected
26