mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
refactoring so that command line options override settings
and Pelican class now accepts a single parameter ``settings``
This commit is contained in:
parent
136e2e46d8
commit
4029f2ec82
4 changed files with 80 additions and 63 deletions
|
|
@ -55,7 +55,11 @@ class TestPelican(unittest.TestCase):
|
|||
with patch("pelican.contents.getenv") as mock_getenv:
|
||||
# force getenv('USER') to always return the same value
|
||||
mock_getenv.return_value = "Dummy Author"
|
||||
pelican = Pelican(path=INPUT_PATH, output_path=self.temp_path)
|
||||
settings = read_settings(filename=None, override={
|
||||
'PATH': INPUT_PATH,
|
||||
'OUTPUT_PATH': self.temp_path,
|
||||
})
|
||||
pelican = Pelican(settings=settings)
|
||||
pelican.run()
|
||||
diff = dircmp(
|
||||
self.temp_path, os.sep.join((OUTPUT_PATH, "basic")))
|
||||
|
|
@ -63,8 +67,11 @@ class TestPelican(unittest.TestCase):
|
|||
|
||||
def test_custom_generation_works(self):
|
||||
# the same thing with a specified set of settings should work
|
||||
pelican = Pelican(path=INPUT_PATH, output_path=self.temp_path,
|
||||
settings=read_settings(SAMPLE_CONFIG))
|
||||
settings = read_settings(filename=SAMPLE_CONFIG, override={
|
||||
'PATH': INPUT_PATH,
|
||||
'OUTPUT_PATH': self.temp_path,
|
||||
})
|
||||
pelican = Pelican(settings=settings)
|
||||
pelican.run()
|
||||
diff = dircmp(self.temp_path, os.sep.join((OUTPUT_PATH, "custom")))
|
||||
self.assertFilesEqual(diff)
|
||||
|
|
|
|||
|
|
@ -56,16 +56,19 @@ class TestSettingsConfiguration(unittest.TestCase):
|
|||
def test_configure_settings(self):
|
||||
"""Manipulations to settings should be applied correctly."""
|
||||
|
||||
# SITEURL should not have a trailing slash
|
||||
settings = {'SITEURL': 'http://blog.notmyidea.org/', 'LOCALE': ''}
|
||||
settings = {
|
||||
'SITEURL': 'http://blog.notmyidea.org/',
|
||||
'LOCALE': '',
|
||||
'PATH': '.',
|
||||
'THEME': DEFAULT_THEME,
|
||||
}
|
||||
configure_settings(settings)
|
||||
# SITEURL should not have a trailing slash
|
||||
self.assertEqual(settings['SITEURL'], 'http://blog.notmyidea.org')
|
||||
|
||||
# FEED_DOMAIN, if undefined, should default to SITEURL
|
||||
settings = {'SITEURL': 'http://blog.notmyidea.org', 'LOCALE': ''}
|
||||
configure_settings(settings)
|
||||
self.assertEqual(settings['FEED_DOMAIN'], 'http://blog.notmyidea.org')
|
||||
|
||||
settings = {'FEED_DOMAIN': 'http://feeds.example.com', 'LOCALE': ''}
|
||||
settings['FEED_DOMAIN'] = 'http://feeds.example.com'
|
||||
configure_settings(settings)
|
||||
self.assertEqual(settings['FEED_DOMAIN'], 'http://feeds.example.com')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue