From 0183882cf78b000745e93d8ac87e2b985e6c26c4 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Wed, 22 Jun 2011 12:22:04 -0500 Subject: [PATCH 1/7] ignoring tags file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 721af351..8e0f0658 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ docs/fr/_build build dist output +tags From 3cd84ab3962f6df97ba62d30ab00db09574edb19 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sat, 2 Jul 2011 14:41:39 -0500 Subject: [PATCH 2/7] moving tests dir --- {pelican/tests => tests}/__init__.py | 0 {pelican/tests => tests}/test_contents.py | 0 {pelican/tests => tests}/test_readers.py | 0 {pelican/tests => tests}/test_settings.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {pelican/tests => tests}/__init__.py (100%) rename {pelican/tests => tests}/test_contents.py (100%) rename {pelican/tests => tests}/test_readers.py (100%) rename {pelican/tests => tests}/test_settings.py (100%) diff --git a/pelican/tests/__init__.py b/tests/__init__.py similarity index 100% rename from pelican/tests/__init__.py rename to tests/__init__.py diff --git a/pelican/tests/test_contents.py b/tests/test_contents.py similarity index 100% rename from pelican/tests/test_contents.py rename to tests/test_contents.py diff --git a/pelican/tests/test_readers.py b/tests/test_readers.py similarity index 100% rename from pelican/tests/test_readers.py rename to tests/test_readers.py diff --git a/pelican/tests/test_settings.py b/tests/test_settings.py similarity index 100% rename from pelican/tests/test_settings.py rename to tests/test_settings.py From dc6934be43d196c1cbf824088bff4292ccbc41b2 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sat, 2 Jul 2011 15:15:21 -0500 Subject: [PATCH 3/7] all test pass --- pelican/settings.py | 13 +++++---- tests/content/article_with_metadata.rst | 11 +++++++ tests/default_conf.py | 38 +++++++++++++++++++++++++ tests/test_readers.py | 6 ++-- tests/test_settings.py | 5 ++-- 5 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 tests/content/article_with_metadata.rst create mode 100755 tests/default_conf.py diff --git a/pelican/settings.py b/pelican/settings.py index 1b32395c..125d0bb0 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -55,6 +55,13 @@ def read_settings(filename): if key.isupper(): 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 locales = context['LOCALE'] @@ -74,11 +81,5 @@ def read_settings(filename): else: 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 return context diff --git a/tests/content/article_with_metadata.rst b/tests/content/article_with_metadata.rst new file mode 100644 index 00000000..3410885e --- /dev/null +++ b/tests/content/article_with_metadata.rst @@ -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**. diff --git a/tests/default_conf.py b/tests/default_conf.py new file mode 100755 index 00000000..2796d561 --- /dev/null +++ b/tests/default_conf.py @@ -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" diff --git a/tests/test_readers.py b/tests/test_readers.py index 5a255209..bf7504fb 100644 --- a/tests/test_readers.py +++ b/tests/test_readers.py @@ -5,7 +5,7 @@ import datetime from pelican import readers 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): return os.path.join(CONTENT_PATH, *args) @@ -13,9 +13,9 @@ def _filename(*args): class RstReaderTest(unittest2.TestCase): - def test_metadata(self): + def test_article_with_metadata(self): reader = readers.RstReader() - content, metadata = reader.read(_filename('super_article.rst')) + content, metadata = reader.read(_filename('article_with_metadata.rst')) expected = { 'category': 'yeah', 'author': u'Alexis Métaireau', diff --git a/tests/test_settings.py b/tests/test_settings.py index 39680a9f..8391e8c6 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -4,12 +4,11 @@ import os from pelican.settings import read_settings, _DEFAULT_CONFIG SETTINGS = os.sep.join([os.path.dirname(os.path.abspath(__file__)), - "../../samples/pelican.conf.py"]) + "default_conf.py"]) class SettingsTest(TestCase): - - def test_read_settings(self): + def test_read_settings_from_file(self): # providing a file, it should read it, replace the default values and append # new values to the settings, if any settings = read_settings(SETTINGS) From d19b0c975b3b53741ed7407f53de8478b5a9bd7e Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sat, 2 Jul 2011 15:53:27 -0500 Subject: [PATCH 4/7] test works with python2.5 --- tests/test_contents.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_contents.py b/tests/test_contents.py index d013da2f..df2c00e6 100644 --- a/tests/test_contents.py +++ b/tests/test_contents.py @@ -1,3 +1,4 @@ +from __future__ import with_statement from unittest2 import TestCase from pelican.contents import Page From 53c19cc9a094348110be7b75849d0ac43555c414 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sat, 2 Jul 2011 15:54:24 -0500 Subject: [PATCH 5/7] adding tox --- .gitignore | 1 + tox.ini | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 8e0f0658..5bb92c09 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build dist output tags +.tox diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..462abf09 --- /dev/null +++ b/tox.ini @@ -0,0 +1,12 @@ +[tox] +envlist = py25,py26,py27 + +[testenv] +commands=py.test +deps = + Jinja2 + Pygments + docutils + feedgenerator + unittest2 + pytest From 3958cbcce36ac9b6aeef9e5dc1bbe94c25697e71 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sat, 2 Jul 2011 15:55:26 -0500 Subject: [PATCH 6/7] removing reqs.txt file: replaced by tox --- dev_requirements.txt | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 dev_requirements.txt diff --git a/dev_requirements.txt b/dev_requirements.txt deleted file mode 100644 index acafebc0..00000000 --- a/dev_requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -Jinja2==2.5.5 -Pygments==1.4 -docutils==0.7 -feedgenerator==1.2.1 -unittest2 From 77aac049fdf0f73534a455af01d4dfe16249538f Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sat, 2 Jul 2011 23:47:22 -0500 Subject: [PATCH 7/7] improved test_setting.py --- tests/test_settings.py | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/test_settings.py b/tests/test_settings.py index 8391e8c6..e32fcef4 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,33 +1,33 @@ -from unittest2 import TestCase -import os +import unittest2 +from os.path import dirname, abspath, join from pelican.settings import read_settings, _DEFAULT_CONFIG -SETTINGS = os.sep.join([os.path.dirname(os.path.abspath(__file__)), - "default_conf.py"]) -class SettingsTest(TestCase): +class TestSettingsFromFile(unittest2.TestCase): + """Providing a file, it should read it, replace the default values and + append new values to the settings, if any + """ + def setUp(self): + self.PATH = abspath(dirname(__file__)) + default_conf = join(self.PATH, 'default_conf.py') + self.settings = read_settings(default_conf) - def test_read_settings_from_file(self): - # providing a file, it should read it, replace the default values and append - # new values to the settings, if any - settings = read_settings(SETTINGS) + def test_overwrite_existing_settings(self): + self.assertEqual(self.settings.get('SITENAME'), u"Alexis' log") + self.assertEqual(self.settings.get('SITEURL'), + 'http://blog.notmyidea.org') - # 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'), + def test_keep_default_settings(self): + """keep default settings if not defined""" + self.assertEqual(self.settings.get('DEFAULT_CATEGORY'), _DEFAULT_CONFIG['DEFAULT_CATEGORY']) - # do not copy keys not in caps - self.assertNotIn('foobar', settings) + def test_dont_copy_small_keys(self): + """do not copy keys not in caps.""" + self.assertNotIn('foobar', self.settings) - - def test_empty_read_settings(self): - # providing no file should return the default values + def test_read_empty_settings(self): + """providing no file should return the default values.""" settings = read_settings(None) self.assertDictEqual(settings, _DEFAULT_CONFIG)