comparison tests/test_routing.py @ 979:45ad976712ec

tests: Big push to get the tests to pass again. - Lots of fixes everywhere in the code. - Try to handle debug logging in the multiprocessing worker pool when running in pytest. Not perfect, but usable for now. - Replace all `.md` test files with `.html` since now a auto-format extension always sets the format. - Replace `out` with `outfiles` in most places since now blog archives are added to the bake output and I don't want to add expected outputs for blog archives everywhere.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 29 Oct 2017 22:51:57 -0700
parents 72f17534d58e
children
comparison
equal deleted inserted replaced
978:7e51d14097cb 979:45ad976712ec
25 src.getSupportedRouteParameters = lambda: route_params 25 src.getSupportedRouteParameters = lambda: route_params
26 return src 26 return src
27 27
28 28
29 @pytest.mark.parametrize( 29 @pytest.mark.parametrize(
30 'config, metadata, params, expected', 30 'config, params, uri_params, expected',
31 [ 31 [
32 ({'url': '/%foo%'}, 32 ({'url': '/%foo%'}, ['foo'], {'foo': 'bar'}, True),
33 {'foo': 'bar'}, ['foo'], True), 33 ({'url': '/%foo%'}, ['foo'], {'zoo': 'zar', 'foo': 'bar'}, True),
34 ({'url': '/%foo%'}, 34 ({'url': '/%foo%'}, ['foo'], {'zoo': 'zar'}, False),
35 {'zoo': 'zar', 'foo': 'bar'}, ['foo'], True), 35 ({'url': '/%foo%/%zoo%'}, ['foo', 'zoo'], {'zoo': 'zar'}, False)
36 ({'url': '/%foo%'}, 36 ])
37 {'zoo': 'zar'}, ['foo'], False), 37 def test_matches_parameters(config, params, uri_params, expected):
38 ({'url': '/%foo%/%zoo%'},
39 {'zoo': 'zar'}, ['foo', 'zoo'], False)
40 ])
41 def test_matches_metadata(config, metadata, params, expected):
42 app = get_mock_app() 38 app = get_mock_app()
43 app.config.set('site/root', '/') 39 app.config.set('site/root', '/')
44 app.sources = [_getMockSource('blah', params)] 40 app.sources = [_getMockSource('blah', params)]
45 41
46 config.setdefault('source', 'blah') 42 config.setdefault('source', 'blah')
47 route = Route(app, config) 43 route = Route(app, config)
48 m = route.matchesMetadata(metadata) 44 m = route.matchesParameters(uri_params)
49 assert m == expected 45 assert m == expected
50 46
51 47
52 @pytest.mark.parametrize( 48 @pytest.mark.parametrize(
53 'site_root, route_pattern, params, expected_func_parameters', 49 'site_root, route_pattern, params, expected_func_parameters',