view tests/test_uriutil.py @ 29:7e44f6092a1d

More unit tests for output bake paths.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 19 Aug 2014 11:51:09 -0700
parents 474c9882decf
children 62c7a97c8340
line wrap: on
line source

import pytest
from piecrust.uriutil import UriInfo, parse_uri


@pytest.mark.parametrize('routes, uri, expected', [
        ({}, '/foo', None),
        (
            {'/articles/%slug%': {'source': 'dummy'}},
            '/articles/foo',
            UriInfo('', 'dummy', {'slug': 'foo'})),
        (
            {'/foo/%bar%': {'source': 'foo'},
                '/other/%one%-%two%': {'source': 'other'}},
            '/other/some-thing',
            UriInfo('', 'other', {'one': 'some', 'two': 'thing'}))
    ])
def test_parse_uri(routes, uri, expected):
    if expected is not None:
        expected.uri = uri
    for pattern, args in routes.items():
        if 'taxonomy' not in args:
            args['taxonomy'] = None

    actual = parse_uri(routes, uri)
    assert actual == expected