1
0
Fork 0
forked from github/pelican

settings: Make DEFAULT_CONFIG public

This dictionary is accessed by plugins (like `summary`) which add new
settings, so it should be public (i.e. no prefixed underscore).

The changed name length would have led to a re-indenting of the
default contents anyway, so I shifted them all to four spaces.
This commit is contained in:
W. Trevor King 2013-03-24 08:38:19 -04:00
commit e9dc1dd478
6 changed files with 105 additions and 108 deletions

View file

@ -18,7 +18,7 @@ from tempfile import mkdtemp
from shutil import rmtree
from pelican.contents import Article
from pelican.settings import _DEFAULT_CONFIG
from pelican.settings import DEFAULT_CONFIG
@contextmanager
@ -162,7 +162,7 @@ def locale_available(locale_):
def get_settings():
settings = _DEFAULT_CONFIG.copy()
settings = DEFAULT_CONFIG.copy()
settings['DIRECT_TEMPLATES'] = ['archives']
settings['filenames'] = {}
return settings

View file

@ -7,7 +7,7 @@ from sys import platform
from .support import unittest
from pelican.contents import Page, Article, URLWrapper
from pelican.settings import _DEFAULT_CONFIG
from pelican.settings import DEFAULT_CONFIG
from pelican.utils import truncate_html_words
from pelican.signals import content_object_init
from jinja2.utils import generate_lorem_ipsum
@ -62,7 +62,7 @@ class TestPage(unittest.TestCase):
# If a :SUMMARY_MAX_LENGTH: is set, and there is no other summary,
# generated summary should not exceed the given length.
page_kwargs = self._copy_page_kwargs()
settings = _DEFAULT_CONFIG.copy()
settings = DEFAULT_CONFIG.copy()
page_kwargs['settings'] = settings
del page_kwargs['metadata']['summary']
settings['SUMMARY_MAX_LENGTH'] = None
@ -83,7 +83,7 @@ class TestPage(unittest.TestCase):
def test_defaultlang(self):
# If no lang is given, default to the default one.
page = Page(**self.page_kwargs)
self.assertEqual(page.lang, _DEFAULT_CONFIG['DEFAULT_LANG'])
self.assertEqual(page.lang, DEFAULT_CONFIG['DEFAULT_LANG'])
# it is possible to specify the lang in the metadata infos
self.page_kwargs['metadata'].update({'lang': 'fr', })
@ -108,7 +108,7 @@ class TestPage(unittest.TestCase):
page = Page(**self.page_kwargs)
self.assertIn('summary', page.url_format.keys())
page.metadata['directory'] = 'test-dir'
page.settings = _DEFAULT_CONFIG.copy()
page.settings = DEFAULT_CONFIG.copy()
page.settings['PAGE_SAVE_AS'] = '{directory}/{slug}'
self.assertEqual(page.save_as, 'test-dir/foo-bar')
@ -123,10 +123,10 @@ class TestPage(unittest.TestCase):
page = Page(**page_kwargs)
self.assertEqual(page.locale_date,
dt.strftime(_DEFAULT_CONFIG['DEFAULT_DATE_FORMAT']))
dt.strftime(DEFAULT_CONFIG['DEFAULT_DATE_FORMAT']))
page_kwargs['settings'] = dict([(x, _DEFAULT_CONFIG[x]) for x in
_DEFAULT_CONFIG])
page_kwargs['settings'] = dict([(x, DEFAULT_CONFIG[x]) for x in
DEFAULT_CONFIG])
# I doubt this can work on all platforms ...
if platform == "win32":

View file

@ -11,7 +11,7 @@ from shutil import rmtree
from pelican.generators import (ArticlesGenerator, PagesGenerator,
TemplatePagesGenerator)
from pelican.writers import Writer
from pelican.settings import _DEFAULT_CONFIG
from pelican.settings import DEFAULT_CONFIG
from pelican.tests.support import unittest, get_settings
CUR_DIR = os.path.dirname(__file__)
@ -117,15 +117,15 @@ class TestArticlesGenerator(unittest.TestCase):
def test_do_not_use_folder_as_category(self):
settings = _DEFAULT_CONFIG.copy()
settings = DEFAULT_CONFIG.copy()
settings['ARTICLE_DIR'] = 'content'
settings['DEFAULT_CATEGORY'] = 'Default'
settings['DEFAULT_DATE'] = (1970, 1, 1)
settings['USE_FOLDER_AS_CATEGORY'] = False
settings['filenames'] = {}
generator = ArticlesGenerator(settings.copy(), settings,
CUR_DIR, _DEFAULT_CONFIG['THEME'], None,
_DEFAULT_CONFIG['MARKUP'])
generator = ArticlesGenerator(
settings.copy(), settings, CUR_DIR, DEFAULT_CONFIG['THEME'], None,
DEFAULT_CONFIG['MARKUP'])
generator.generate_context()
# test for name
# categories are grouped by slug; if two categories have the same slug

View file

@ -5,7 +5,7 @@ import os
from os.path import dirname, abspath, join
from pelican.settings import (read_settings, configure_settings,
_DEFAULT_CONFIG, DEFAULT_THEME)
DEFAULT_CONFIG, DEFAULT_THEME)
from pelican.tests.support import unittest
@ -27,7 +27,7 @@ class TestSettingsConfiguration(unittest.TestCase):
def test_keep_default_settings(self):
# Keep default settings if not defined.
self.assertEqual(self.settings.get('DEFAULT_CATEGORY'),
_DEFAULT_CONFIG['DEFAULT_CATEGORY'])
DEFAULT_CONFIG['DEFAULT_CATEGORY'])
def test_dont_copy_small_keys(self):
# Do not copy keys not in caps.
@ -36,7 +36,7 @@ class TestSettingsConfiguration(unittest.TestCase):
def test_read_empty_settings(self):
# Providing no file should return the default values.
settings = read_settings(None)
expected = copy.deepcopy(_DEFAULT_CONFIG)
expected = copy.deepcopy(DEFAULT_CONFIG)
expected['FEED_DOMAIN'] = '' # Added by configure settings
self.maxDiff = None
self.assertDictEqual(settings, expected)
@ -55,7 +55,7 @@ class TestSettingsConfiguration(unittest.TestCase):
# This assumes 'SITENAME': 'A Pelican Blog'
settings = read_settings(None)
settings['SITENAME'] = 'Not a Pelican Blog'
self.assertNotEqual(settings['SITENAME'], _DEFAULT_CONFIG['SITENAME'])
self.assertNotEqual(settings['SITENAME'], DEFAULT_CONFIG['SITENAME'])
def test_path_settings_safety(self):
"""Don't let people setting the static path listings to strs"""
@ -69,9 +69,9 @@ class TestSettingsConfiguration(unittest.TestCase):
}
configure_settings(settings)
self.assertEqual(settings['STATIC_PATHS'],
_DEFAULT_CONFIG['STATIC_PATHS'])
DEFAULT_CONFIG['STATIC_PATHS'])
self.assertEqual(settings['THEME_STATIC_PATHS'],
_DEFAULT_CONFIG['THEME_STATIC_PATHS'])
DEFAULT_CONFIG['THEME_STATIC_PATHS'])
def test_configure_settings(self):
#Manipulations to settings should be applied correctly.