annotate tests/test_appconfig.py @ 661:2f780b191541

internal: Fix a bug with registering taxonomy terms that are not strings. Some objects, like the blog data provider's taxnonomy entries, can render as strings, but are objects themselves. When registering them as "used terms", we need to use their string representation.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 01 Mar 2016 22:26:09 -0800
parents 25df894f9ab9
children 3df808b133f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
584
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
1 from piecrust.appconfig import PieCrustConfiguration
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 def test_config_default():
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5 values = {}
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6 config = PieCrustConfiguration(values=values)
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7 assert config.get('site/root') == '/'
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
8 assert len(config.get('site/sources')) == 3 # pages, posts, theme_pages
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11 def test_config_default2():
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12 config = PieCrustConfiguration()
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13 assert config.get('site/root') == '/'
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
14 assert len(config.get('site/sources')) == 3 # pages, posts, theme_pages
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
15
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17 def test_config_site_override_title():
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
18 values = {'site': {'title': "Whatever"}}
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19 config = PieCrustConfiguration(values=values)
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
20 assert config.get('site/root') == '/'
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21 assert config.get('site/title') == 'Whatever'
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
22
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
23
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24 def test_config_site_add_source():
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25 values = {'site': {
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
26 'sources': {'notes': {}},
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
27 'routes': [{'url': '/notes/%path:slug%', 'source': 'notes'}]
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
28 }}
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
29 config = PieCrustConfiguration(values=values)
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
30 # The order of routes is important. Sources, not so much.
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
31 assert list(map(lambda v: v['source'], config.get('site/routes'))) == [
585
25df894f9ab9 internal: Some fixes to the new app configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 584
diff changeset
32 'notes', 'posts', 'posts', 'posts', 'pages', 'theme_pages']
584
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
33 assert list(config.get('site/sources').keys()) == [
585
25df894f9ab9 internal: Some fixes to the new app configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 584
diff changeset
34 'pages', 'posts', 'notes', 'theme_pages']
584
9ccc933ac2c7 internal: Refactor the app configuration class.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
35