mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
all test pass
This commit is contained in:
parent
3cd84ab396
commit
dc6934be43
5 changed files with 61 additions and 12 deletions
|
|
@ -55,6 +55,13 @@ def read_settings(filename):
|
||||||
if key.isupper():
|
if key.isupper():
|
||||||
context[key] = tempdict[key]
|
context[key] = tempdict[key]
|
||||||
|
|
||||||
|
# Make the paths relative to the settings file
|
||||||
|
for path in ['PATH', 'OUTPUT_PATH']:
|
||||||
|
if path in context:
|
||||||
|
if context[path] is not None and not os.path.isabs(context[path]):
|
||||||
|
# FIXME:
|
||||||
|
context[path] = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(filename), context[path])))
|
||||||
|
|
||||||
# if locales is not a list, make it one
|
# if locales is not a list, make it one
|
||||||
locales = context['LOCALE']
|
locales = context['LOCALE']
|
||||||
|
|
||||||
|
|
@ -74,11 +81,5 @@ def read_settings(filename):
|
||||||
else:
|
else:
|
||||||
log.warn("LOCALE option doesn't contain a correct value")
|
log.warn("LOCALE option doesn't contain a correct value")
|
||||||
|
|
||||||
# Make the paths relative to the settings file
|
|
||||||
for path in ['PATH', 'OUTPUT_PATH']:
|
|
||||||
if path in context:
|
|
||||||
if context[path] is not None and not os.path.isabs(context[path]):
|
|
||||||
context[path] = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(filename), context[path])))
|
|
||||||
|
|
||||||
# set the locale
|
# set the locale
|
||||||
return context
|
return context
|
||||||
|
|
|
||||||
11
tests/content/article_with_metadata.rst
Normal file
11
tests/content/article_with_metadata.rst
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
This is a super article !
|
||||||
|
#########################
|
||||||
|
|
||||||
|
:tags: foo, bar, foobar
|
||||||
|
:date: 2010-12-02 10:14
|
||||||
|
:category: yeah
|
||||||
|
:author: Alexis Métaireau
|
||||||
|
:summary:
|
||||||
|
Multi-line metadata should be supported
|
||||||
|
as well as **inline markup**.
|
||||||
38
tests/default_conf.py
Executable file
38
tests/default_conf.py
Executable file
|
|
@ -0,0 +1,38 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
AUTHOR = u'Alexis Métaireau'
|
||||||
|
SITENAME = u"Alexis' log"
|
||||||
|
SITEURL = 'http://blog.notmyidea.org'
|
||||||
|
|
||||||
|
GITHUB_URL = 'http://github.com/ametaireau/'
|
||||||
|
DISQUS_SITENAME = "blog-notmyidea"
|
||||||
|
PDF_GENERATOR = False
|
||||||
|
REVERSE_CATEGORY_ORDER = True
|
||||||
|
LOCALE = ""
|
||||||
|
DEFAULT_PAGINATION = 2
|
||||||
|
|
||||||
|
FEED_RSS = 'feeds/all.rss.xml'
|
||||||
|
CATEGORY_FEED_RSS = 'feeds/%s.rss.xml'
|
||||||
|
|
||||||
|
LINKS = (('Biologeek', 'http://biologeek.org'),
|
||||||
|
('Filyb', "http://filyb.info/"),
|
||||||
|
('Libert-fr', "http://www.libert-fr.com"),
|
||||||
|
('N1k0', "http://prendreuncafe.com/blog/"),
|
||||||
|
(u'Tarek Ziadé', "http://ziade.org/blog"),
|
||||||
|
('Zubin Mithra', "http://zubin71.wordpress.com/"),)
|
||||||
|
|
||||||
|
SOCIAL = (('twitter', 'http://twitter.com/ametaireau'),
|
||||||
|
('lastfm', 'http://lastfm.com/user/akounet'),
|
||||||
|
('github', 'http://github.com/ametaireau'),)
|
||||||
|
|
||||||
|
# global metadata to all the contents
|
||||||
|
DEFAULT_METADATA = (('yeah', 'it is'),)
|
||||||
|
|
||||||
|
# static paths will be copied under the same name
|
||||||
|
STATIC_PATHS = ["pictures",]
|
||||||
|
|
||||||
|
# A list of files to copy from the source to the destination
|
||||||
|
FILES_TO_COPY = (('extra/robots.txt', 'robots.txt'),)
|
||||||
|
|
||||||
|
# foobar will not be used, because it's not in caps. All configuration keys
|
||||||
|
# have to be in caps
|
||||||
|
foobar = "barbaz"
|
||||||
|
|
@ -5,7 +5,7 @@ import datetime
|
||||||
from pelican import readers
|
from pelican import readers
|
||||||
|
|
||||||
CUR_DIR = os.path.dirname(__file__)
|
CUR_DIR = os.path.dirname(__file__)
|
||||||
CONTENT_PATH = os.path.join(CUR_DIR, '..', '..', 'samples', 'content')
|
CONTENT_PATH = os.path.join(CUR_DIR, 'content')
|
||||||
|
|
||||||
def _filename(*args):
|
def _filename(*args):
|
||||||
return os.path.join(CONTENT_PATH, *args)
|
return os.path.join(CONTENT_PATH, *args)
|
||||||
|
|
@ -13,9 +13,9 @@ def _filename(*args):
|
||||||
|
|
||||||
class RstReaderTest(unittest2.TestCase):
|
class RstReaderTest(unittest2.TestCase):
|
||||||
|
|
||||||
def test_metadata(self):
|
def test_article_with_metadata(self):
|
||||||
reader = readers.RstReader()
|
reader = readers.RstReader()
|
||||||
content, metadata = reader.read(_filename('super_article.rst'))
|
content, metadata = reader.read(_filename('article_with_metadata.rst'))
|
||||||
expected = {
|
expected = {
|
||||||
'category': 'yeah',
|
'category': 'yeah',
|
||||||
'author': u'Alexis Métaireau',
|
'author': u'Alexis Métaireau',
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,11 @@ import os
|
||||||
from pelican.settings import read_settings, _DEFAULT_CONFIG
|
from pelican.settings import read_settings, _DEFAULT_CONFIG
|
||||||
|
|
||||||
SETTINGS = os.sep.join([os.path.dirname(os.path.abspath(__file__)),
|
SETTINGS = os.sep.join([os.path.dirname(os.path.abspath(__file__)),
|
||||||
"../../samples/pelican.conf.py"])
|
"default_conf.py"])
|
||||||
|
|
||||||
class SettingsTest(TestCase):
|
class SettingsTest(TestCase):
|
||||||
|
|
||||||
|
def test_read_settings_from_file(self):
|
||||||
def test_read_settings(self):
|
|
||||||
# providing a file, it should read it, replace the default values and append
|
# providing a file, it should read it, replace the default values and append
|
||||||
# new values to the settings, if any
|
# new values to the settings, if any
|
||||||
settings = read_settings(SETTINGS)
|
settings = read_settings(SETTINGS)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue