comparison tests/test_appconfig.py @ 675:3df808b133f8

internal: Improve how theme configuration is validated and merged. * Add default theme config up-front so it benefits from the usual validation. * Add an explicit `use_default_theme_content` setting. * Add/fix unit tests.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 06 Mar 2016 23:49:41 -0800
parents 25df894f9ab9
children 894d286b348f
comparison
equal deleted inserted replaced
674:f987b29d6fab 675:3df808b133f8
3 3
4 def test_config_default(): 4 def test_config_default():
5 values = {} 5 values = {}
6 config = PieCrustConfiguration(values=values) 6 config = PieCrustConfiguration(values=values)
7 assert config.get('site/root') == '/' 7 assert config.get('site/root') == '/'
8 assert len(config.get('site/sources')) == 3 # pages, posts, theme_pages 8 assert len(config.get('site/sources')) == 2 # pages, posts
9 9
10 10
11 def test_config_default2(): 11 def test_config_default2():
12 config = PieCrustConfiguration() 12 config = PieCrustConfiguration()
13 assert config.get('site/root') == '/' 13 assert config.get('site/root') == '/'
14 assert len(config.get('site/sources')) == 3 # pages, posts, theme_pages 14 assert len(config.get('site/sources')) == 2 # pages, posts
15 15
16 16
17 def test_config_site_override_title(): 17 def test_config_site_override_title():
18 values = {'site': {'title': "Whatever"}} 18 values = {'site': {'title': "Whatever"}}
19 config = PieCrustConfiguration(values=values) 19 config = PieCrustConfiguration(values=values)
27 'routes': [{'url': '/notes/%path:slug%', 'source': 'notes'}] 27 'routes': [{'url': '/notes/%path:slug%', 'source': 'notes'}]
28 }} 28 }}
29 config = PieCrustConfiguration(values=values) 29 config = PieCrustConfiguration(values=values)
30 # The order of routes is important. Sources, not so much. 30 # The order of routes is important. Sources, not so much.
31 assert list(map(lambda v: v['source'], config.get('site/routes'))) == [ 31 assert list(map(lambda v: v['source'], config.get('site/routes'))) == [
32 'notes', 'posts', 'posts', 'posts', 'pages', 'theme_pages'] 32 'notes', 'posts', 'posts', 'posts', 'pages']
33 assert list(config.get('site/sources').keys()) == [ 33 assert list(config.get('site/sources').keys()) == [
34 'pages', 'posts', 'notes', 'theme_pages'] 34 'pages', 'posts', 'notes']
35 35