1
0
Fork 0
forked from github/pelican
pelican-theme/tests/test_settings.py

33 lines
1.1 KiB
Python
Raw Normal View History

2011-01-13 00:46:10 +01:00
from unittest2 import TestCase
import os
from pelican.settings import read_settings, _DEFAULT_CONFIG
2011-01-13 00:46:10 +01:00
SETTINGS = os.sep.join([os.path.dirname(os.path.abspath(__file__)),
2011-07-02 15:15:21 -05:00
"default_conf.py"])
2011-01-13 00:46:10 +01:00
class SettingsTest(TestCase):
2011-07-02 15:15:21 -05:00
def test_read_settings_from_file(self):
2011-01-13 00:46:10 +01:00
# providing a file, it should read it, replace the default values and append
# new values to the settings, if any
settings = read_settings(SETTINGS)
# overwrite existing settings
self.assertEqual(settings.get('SITENAME'), u"Alexis' log")
# add new settings
self.assertEqual(settings.get('SITEURL'), 'http://blog.notmyidea.org')
# keep default settings if not defined
self.assertEqual(settings.get('DEFAULT_CATEGORY'),
_DEFAULT_CONFIG['DEFAULT_CATEGORY'])
2011-01-13 00:46:10 +01:00
# do not copy keys not in caps
self.assertNotIn('foobar', settings)
def test_empty_read_settings(self):
# providing no file should return the default values
settings = read_settings(None)
self.assertDictEqual(settings, _DEFAULT_CONFIG)