tests: Update tests after filename/filepath -> source_path

This commit is contained in:
W. Trevor King 2013-01-04 11:22:49 -05:00
commit 54a9132aea
4 changed files with 29 additions and 29 deletions

View file

@ -229,20 +229,20 @@ class TestTemplatePagesGenerator(unittest.TestCase):
# create a dummy template file
template_dir = os.path.join(self.temp_content, 'template')
template_filename = os.path.join(template_dir, 'source.html')
template_path = os.path.join(template_dir, 'source.html')
os.makedirs(template_dir)
with open(template_filename, 'w') as template_file:
with open(template_path, 'w') as template_file:
template_file.write(self.TEMPLATE_CONTENT)
writer = Writer(self.temp_output, settings=settings)
generator.generate_output(writer)
output_filename = os.path.join(
output_path = os.path.join(
self.temp_output, 'generated', 'file.html')
# output file has been generated
self.assertTrue(os.path.exists(output_filename))
self.assertTrue(os.path.exists(output_path))
# output content is correct
with open(output_filename, 'r') as output_file:
with open(output_path, 'r') as output_file:
self.assertEquals(output_file.read(), 'foo: bar')

View file

@ -70,7 +70,7 @@ class TestPelican(unittest.TestCase):
def test_basic_generation_works(self):
# when running pelican without settings, it should pick up the default
# ones and generate correct output without raising any exception
settings = read_settings(filename=None, override={
settings = read_settings(path=None, override={
'PATH': INPUT_PATH,
'OUTPUT_PATH': self.temp_path,
'LOCALE': locale.normalize('en_US'),
@ -86,7 +86,7 @@ class TestPelican(unittest.TestCase):
def test_custom_generation_works(self):
# the same thing with a specified set of settings should work
settings = read_settings(filename=SAMPLE_CONFIG, override={
settings = read_settings(path=SAMPLE_CONFIG, override={
'PATH': INPUT_PATH,
'OUTPUT_PATH': self.temp_path,
'LOCALE': locale.normalize('en_US'),

View file

@ -11,7 +11,7 @@ CUR_DIR = os.path.dirname(__file__)
CONTENT_PATH = os.path.join(CUR_DIR, 'content')
def _filename(*args):
def _path(*args):
return os.path.join(CONTENT_PATH, *args)
@ -19,7 +19,7 @@ class RstReaderTest(unittest.TestCase):
def test_article_with_metadata(self):
reader = readers.RstReader({})
content, metadata = reader.read(_filename('article_with_metadata.rst'))
content, metadata = reader.read(_path('article_with_metadata.rst'))
expected = {
'category': 'yeah',
'author': 'Alexis Métaireau',
@ -37,7 +37,7 @@ class RstReaderTest(unittest.TestCase):
def test_article_with_filename_metadata(self):
content, metadata = readers.read_file(
_filename('2012-11-29_rst_w_filename_meta#foo-bar.rst'),
_path('2012-11-29_rst_w_filename_meta#foo-bar.rst'),
settings={})
expected = {
'category': 'yeah',
@ -48,7 +48,7 @@ class RstReaderTest(unittest.TestCase):
self.assertEquals(value, expected[key], key)
content, metadata = readers.read_file(
_filename('2012-11-29_rst_w_filename_meta#foo-bar.rst'),
_path('2012-11-29_rst_w_filename_meta#foo-bar.rst'),
settings={
'FILENAME_METADATA': '(?P<date>\d{4}-\d{2}-\d{2}).*'
})
@ -62,7 +62,7 @@ class RstReaderTest(unittest.TestCase):
self.assertEquals(value, expected[key], key)
content, metadata = readers.read_file(
_filename('2012-11-29_rst_w_filename_meta#foo-bar.rst'),
_path('2012-11-29_rst_w_filename_meta#foo-bar.rst'),
settings={
'FILENAME_METADATA': '(?P<date>\d{4}-\d{2}-\d{2})_' \
'_(?P<Slug>.*)' \
@ -82,7 +82,7 @@ class RstReaderTest(unittest.TestCase):
def test_article_metadata_key_lowercase(self):
"""Keys of metadata should be lowercase."""
reader = readers.RstReader({})
content, metadata = reader.read(_filename('article_with_uppercase_metadata.rst'))
content, metadata = reader.read(_path('article_with_uppercase_metadata.rst'))
self.assertIn('category', metadata, "Key should be lowercase.")
self.assertEquals('Yeah', metadata.get('category'), "Value keeps cases.")
@ -90,7 +90,7 @@ class RstReaderTest(unittest.TestCase):
def test_typogrify(self):
# if nothing is specified in the settings, the content should be
# unmodified
content, _ = readers.read_file(_filename('article.rst'))
content, _ = readers.read_file(_path('article.rst'))
expected = "<p>This is some content. With some stuff to "\
"&quot;typogrify&quot;.</p>\n<p>Now with added "\
'support for <abbr title="three letter acronym">'\
@ -100,7 +100,7 @@ class RstReaderTest(unittest.TestCase):
try:
# otherwise, typogrify should be applied
content, _ = readers.read_file(_filename('article.rst'),
content, _ = readers.read_file(_path('article.rst'),
settings={'TYPOGRIFY': True})
expected = "<p>This is some content. With some stuff to&nbsp;"\
"&#8220;typogrify&#8221;.</p>\n<p>Now with added "\
@ -118,7 +118,7 @@ class MdReaderTest(unittest.TestCase):
def test_article_with_md_extension(self):
# test to ensure the md extension is being processed by the correct reader
reader = readers.MarkdownReader({})
content, metadata = reader.read(_filename('article_with_md_extension.md'))
content, metadata = reader.read(_path('article_with_md_extension.md'))
expected = "<h1>Test Markdown File Header</h1>\n"\
"<h2>Used for pelican test</h2>\n"\
"<p>The quick brown fox jumped over the lazy dog's back.</p>"
@ -136,7 +136,7 @@ class MdReaderTest(unittest.TestCase):
def test_article_with_mkd_extension(self):
# test to ensure the mkd extension is being processed by the correct reader
reader = readers.MarkdownReader({})
content, metadata = reader.read(_filename('article_with_mkd_extension.mkd'))
content, metadata = reader.read(_path('article_with_mkd_extension.mkd'))
expected = "<h1>Test Markdown File Header</h1>\n"\
"<h2>Used for pelican test</h2>\n"\
"<p>This is another markdown test file. Uses the mkd extension.</p>"
@ -147,7 +147,7 @@ class MdReaderTest(unittest.TestCase):
def test_article_with_markdown_markup_extension(self):
# test to ensure the markdown markup extension is being processed as expected
content, metadata = readers.read_file(
_filename('article_with_markdown_markup_extensions.md'),
_path('article_with_markdown_markup_extensions.md'),
settings={'MD_EXTENSIONS': ['toc', 'codehilite', 'extra']})
expected = '<div class="toc">\n'\
'<ul>\n'\
@ -165,7 +165,7 @@ class MdReaderTest(unittest.TestCase):
@unittest.skipUnless(readers.Markdown, "markdown isn't installed")
def test_article_with_filename_metadata(self):
content, metadata = readers.read_file(
_filename('2012-11-30_md_w_filename_meta#foo-bar.md'),
_path('2012-11-30_md_w_filename_meta#foo-bar.md'),
settings={})
expected = {
'category': 'yeah',
@ -175,7 +175,7 @@ class MdReaderTest(unittest.TestCase):
self.assertEquals(value, metadata[key], key)
content, metadata = readers.read_file(
_filename('2012-11-30_md_w_filename_meta#foo-bar.md'),
_path('2012-11-30_md_w_filename_meta#foo-bar.md'),
settings={
'FILENAME_METADATA': '(?P<date>\d{4}-\d{2}-\d{2}).*'
})
@ -188,7 +188,7 @@ class MdReaderTest(unittest.TestCase):
self.assertEquals(value, metadata[key], key)
content, metadata = readers.read_file(
_filename('2012-11-30_md_w_filename_meta#foo-bar.md'),
_path('2012-11-30_md_w_filename_meta#foo-bar.md'),
settings={
'FILENAME_METADATA': '(?P<date>\d{4}-\d{2}-\d{2})'
'_(?P<Slug>.*)'
@ -210,7 +210,7 @@ class AdReaderTest(unittest.TestCase):
def test_article_with_asc_extension(self):
# test to ensure the asc extension is being processed by the correct reader
reader = readers.AsciiDocReader({})
content, metadata = reader.read(_filename('article_with_asc_extension.asc'))
content, metadata = reader.read(_path('article_with_asc_extension.asc'))
expected = '<hr>\n<h2><a name="_used_for_pelican_test"></a>Used for pelican test</h2>\n'\
'<p>The quick brown fox jumped over the lazy dog&#8217;s back.</p>\n'
self.assertEqual(content, expected)
@ -241,7 +241,7 @@ class AdReaderTest(unittest.TestCase):
def test_article_with_asc_options(self):
# test to ensure the ASCIIDOC_OPTIONS is being used
reader = readers.AsciiDocReader(dict(ASCIIDOC_OPTIONS=["-a revision=1.0.42"]))
content, metadata = reader.read(_filename('article_with_asc_options.asc'))
content, metadata = reader.read(_path('article_with_asc_options.asc'))
expected = '<hr>\n<h2><a name="_used_for_pelican_test"></a>Used for pelican test</h2>\n'\
'<p>version 1.0.42</p>\n'\
'<p>The quick brown fox jumped over the lazy dog&#8217;s back.</p>\n'

View file

@ -79,17 +79,17 @@ class TestUtils(unittest.TestCase):
"""Test if file changes are correctly detected
Make sure to handle not getting any files correctly"""
path = os.path.join(os.path.dirname(__file__), 'content')
filename = os.path.join(path, 'article_with_metadata.rst')
changed = utils.files_changed(path, 'rst')
dirname = os.path.join(os.path.dirname(__file__), 'content')
path = os.path.join(dirname, 'article_with_metadata.rst')
changed = utils.files_changed(dirname, 'rst')
self.assertEquals(changed, True)
changed = utils.files_changed(path, 'rst')
changed = utils.files_changed(dirname, 'rst')
self.assertEquals(changed, False)
t = time.time()
os.utime(filename, (t, t))
changed = utils.files_changed(path, 'rst')
os.utime(path, (t, t))
changed = utils.files_changed(dirname, 'rst')
self.assertEquals(changed, True)
self.assertAlmostEqual(utils.LAST_MTIME, t, delta=1)