Mercurial > piecrust2
diff tests/test_appconfig.py @ 681:894d286b348f
internal: Refactor config loading some more.
* Remove fixup code in the app to make the app config class more standalone.
* Remove support for old-style variants... maybe bring it back later.
* Try and fix various bugs introduced by subtle config value overriding order
changes.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 08 Mar 2016 01:07:34 -0800 |
parents | 3df808b133f8 |
children | ec384174b8b2 |
line wrap: on
line diff
--- a/tests/test_appconfig.py Tue Mar 08 01:05:39 2016 -0800 +++ b/tests/test_appconfig.py Tue Mar 08 01:07:34 2016 -0800 @@ -1,4 +1,5 @@ from piecrust.appconfig import PieCrustConfiguration +from .mockutil import mock_fs, mock_fs_scope def test_config_default(): @@ -28,8 +29,28 @@ }} config = PieCrustConfiguration(values=values) # The order of routes is important. Sources, not so much. + # `posts` shows up 3 times in routes (posts, tags, categories) assert list(map(lambda v: v['source'], config.get('site/routes'))) == [ 'notes', 'posts', 'posts', 'posts', 'pages'] - assert list(config.get('site/sources').keys()) == [ - 'pages', 'posts', 'notes'] + assert sorted(config.get('site/sources').keys()) == sorted([ + 'pages', 'posts', 'notes']) + +def test_config_site_add_source_with_theme(): + config = {'site': { + 'sources': {'notes': {}}, + 'routes': [{'url': '/notes/%path:slug%', 'source': 'notes'}] + }} + fs = mock_fs().withConfig(config) + with mock_fs_scope(fs): + app = fs.getApp() + # The order of routes is important. Sources, not so much. + # `posts` shows up 3 times in routes (posts, tags, categories) + assert (list( + map( + lambda v: v['source'], + app.config.get('site/routes'))) == + ['notes', 'posts', 'posts', 'posts', 'pages', 'theme_pages']) + assert sorted(app.config.get('site/sources').keys()) == sorted([ + 'pages', 'posts', 'notes', 'theme_pages']) +