aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLibravatarAgustin Henze <tin@sluc.org.ar>2015-07-08 07:35:02 -0300
committerLibravatarAgustin Henze <tin@sluc.org.ar>2015-07-08 07:35:02 -0300
commitb0b24795b24ee6809397fbbadf42f31f310a219f (patch)
tree46d05bb47460b4ec679211717c4ab07414b80d9c /tests
parent5ec02211214350ee558fd9f6bb052264fd24f75e (diff)
Imported Upstream version 7.6.0upstream/7.6.0
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py1
-rw-r--r--tests/base.py2
-rw-r--r--tests/data/translated_titles/conf.py12
-rw-r--r--tests/test_command_import_wordpress.py52
-rw-r--r--tests/test_integration.py128
-rw-r--r--tests/test_rss_feeds.py11
-rw-r--r--tests/test_rst_compiler.py4
-rw-r--r--tests/test_utils.py18
8 files changed, 156 insertions, 72 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index e69de29..ed1acfa 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -0,0 +1 @@
+# Tests for Nikola.
diff --git a/tests/base.py b/tests/base.py
index a244f6a..f0bd484 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -203,6 +203,7 @@ class FakeSite(object):
'DEFAULT_LANG': 'en',
'MARKDOWN_EXTENSIONS': ['fenced_code', 'codehilite'],
'TRANSLATIONS_PATTERN': '{path}.{lang}.{ext}',
+ 'LISTINGS_FOLDERS': {'listings': 'listings'},
}
self.EXTRA_PLUGINS = self.config['EXTRA_PLUGINS']
self.plugin_manager = PluginManager(categories_filter={
@@ -233,6 +234,7 @@ class FakeSite(object):
slug='fake-post')
]
self.debug = True
+ self.rst_transforms = []
# This is to make plugin initialization happy
self.template_system = self
self.name = 'mako'
diff --git a/tests/data/translated_titles/conf.py b/tests/data/translated_titles/conf.py
index 4904586..3d0d829 100644
--- a/tests/data/translated_titles/conf.py
+++ b/tests/data/translated_titles/conf.py
@@ -23,10 +23,10 @@ BLOG_AUTHOR = "Your Name" # (translatable)
BLOG_TITLE = "Demo Site" # (translatable)
# This is the main URL for your site. It will be used
# in a prominent link
-SITE_URL = "http://getnikola.com/"
+SITE_URL = "https://example.com/"
# This is the URL where nikola's output will be deployed.
# If not set, defaults to SITE_URL
-# BASE_URL = "http://getnikola.com/"
+# BASE_URL = "https://example.com/"
BLOG_EMAIL = "joe@demo.site"
BLOG_DESCRIPTION = "This is a demo site for Nikola." # (translatable)
@@ -279,7 +279,7 @@ REDIRECTIONS = []
# By default, there are no filters.
#
# Many filters are shipped with Nikola. A list is available in the manual:
-# <http://getnikola.com/handbook.html#post-processing-filters>
+# <https://getnikola.com/handbook.html#post-processing-filters>
# FILTERS = {
# ".jpg": ["jpegoptim --strip-all -m75 -v %s"],
# }
@@ -394,7 +394,7 @@ LICENSE = ""
# A small copyright notice for the page footer (in HTML).
# (translatable)
-CONTENT_FOOTER = 'Contents &copy; {date} <a href="mailto:{email}">{author}</a> - Powered by <a href="http://getnikola.com" rel="nofollow">Nikola</a> {license}'
+CONTENT_FOOTER = 'Contents &copy; {date} <a href="mailto:{email}">{author}</a> - Powered by <a href="https://getnikola.com/" rel="nofollow">Nikola</a> {license}'
# Things that will be passed to CONTENT_FOOTER.format(). This is done
# for translatability, as dicts are not formattable. Nikola will
@@ -625,8 +625,8 @@ COMMENT_SYSTEM_ID = "nikolademo"
# Use content distribution networks for jquery and twitter-bootstrap css and js
-# If this is True, jquery is served from the Google CDN and twitter-bootstrap
-# is served from the NetDNA CDN
+# If this is True, jquery and html5shiv are served from the Google CDN and
+# Bootstrap is served from BootstrapCDN (provided by MaxCDN)
# Set this to False if you want to host your site without requiring access to
# external resources.
# USE_CDN = False
diff --git a/tests/test_command_import_wordpress.py b/tests/test_command_import_wordpress.py
index fafb10c..2c47bc3 100644
--- a/tests/test_command_import_wordpress.py
+++ b/tests/test_command_import_wordpress.py
@@ -25,29 +25,6 @@ class BasicCommandImportWordpress(BaseTestCase):
del self.import_filename
-class TestXMLGlueing(BasicCommandImportWordpress):
- def test_making_correct_newlines(self):
- xml = [b"Some information about how to (un)subscripe to a google group with a normal mail client.\n",
- b"<ul>\n",
- b" <li>to post: <strong>groupname@googlegroups.com</strong></li>\n",
- b" <li>to <em>subscribe</em>: <strong>groupname+subscribe@googlegroups.com</strong></li>\n",
- b" <li>to <em>unsubscribe</em>: <strong>groupname+unsubscribe@googlegroups.com</strong></li>\n",
- b"</ul>\n",
- b"Easy.\n"]
-
- expected_xml = b"""Some information about how to (un)subscripe to a google group with a normal mail client.
-
-<ul>
- <li>to post: <strong>groupname@googlegroups.com</strong></li>
- <li>to <em>subscribe</em>: <strong>groupname+subscribe@googlegroups.com</strong></li>
- <li>to <em>unsubscribe</em>: <strong>groupname+unsubscribe@googlegroups.com</strong></li>
-</ul>
-
-Easy.
-"""
- self.assertEqual(expected_xml, self.import_command._glue_xml_lines(xml))
-
-
class TestQTranslateContentSeparation(BasicCommandImportWordpress):
def test_conserves_qtranslate_less_post(self):
@@ -241,7 +218,7 @@ class CommandImportWordpressTest(BasicCommandImportWordpress):
self.assertTrue(write_metadata.called)
write_metadata.assert_any_call(
'new_site/stories/kontakt.meta'.replace('/', os.sep), 'Kontakt',
- 'kontakt', '2009-07-16 20:20:32', None, [])
+ 'kontakt', '2009-07-16 20:20:32', '', [])
self.assertTrue(write_content.called)
write_content.assert_any_call('new_site/posts/2007/04/hoert.wp'.replace('/', os.sep),
@@ -251,13 +228,13 @@ class CommandImportWordpressTest(BasicCommandImportWordpress):
Some source code.
-~~~~~~~~~~~~{.Python}
+```Python
import sys
print sys.version
-~~~~~~~~~~~~
+```
The end.
@@ -266,17 +243,25 @@ The end.
write_content.assert_any_call(
'new_site/posts/2008/07/arzt-und-pfusch-s-i-c-k.wp'.replace('/', os.sep),
'''<img class="size-full wp-image-10 alignright" title="Arzt+Pfusch - S.I.C.K." src="http://some.blog/wp-content/uploads/2008/07/arzt_und_pfusch-sick-cover.png" alt="Arzt+Pfusch - S.I.C.K." width="210" height="209" />Arzt+Pfusch - S.I.C.K.Gerade bin ich \xfcber das Album <em>S.I.C.K</em> von <a title="Arzt+Pfusch" href="http://www.arztpfusch.com/" target="_blank">Arzt+Pfusch</a> gestolpert, welches Arzt+Pfusch zum Download f\xfcr lau anbieten. Das Album steht unter einer Creative Commons <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/de/">BY-NC-ND</a>-Lizenz.
+
Die Ladung <em>noisebmstupidevildustrial</em> gibts als MP3s mit <a href="http://www.archive.org/download/dmp005/dmp005_64kb_mp3.zip">64kbps</a> und <a href="http://www.archive.org/download/dmp005/dmp005_vbr_mp3.zip">VBR</a>, als Ogg Vorbis und als FLAC (letztere <a href="http://www.archive.org/details/dmp005">hier</a>). <a href="http://www.archive.org/download/dmp005/dmp005-artwork.zip">Artwork</a> und <a href="http://www.archive.org/download/dmp005/dmp005-lyrics.txt">Lyrics</a> gibts nochmal einzeln zum Download.''')
write_content.assert_any_call(
'new_site/stories/kontakt.wp'.replace('/', os.sep), """<h1>Datenschutz</h1>
+
Ich erhebe und speichere automatisch in meine Server Log Files Informationen, die dein Browser an mich \xfcbermittelt. Dies sind:
<ul>
+
<li>Browsertyp und -version</li>
+
<li>verwendetes Betriebssystem</li>
+
<li>Referrer URL (die zuvor besuchte Seite)</li>
+
<li>IP Adresse des zugreifenden Rechners</li>
+
<li>Uhrzeit der Serveranfrage.</li>
+
</ul>
Diese Daten sind f\xfcr mich nicht bestimmten Personen zuordenbar. Eine Zusammenf\xfchrung dieser Daten mit anderen Datenquellen wird nicht vorgenommen, die Daten werden einzig zu statistischen Zwecken erhoben.""")
@@ -317,16 +302,16 @@ Diese Daten sind f\xfcr mich nicht bestimmten Personen zuordenbar. Eine Zusammen
def test_transforming_content(self):
"""Applying markup conversions to content."""
- transform_sourcecode = mock.MagicMock()
+ transform_code = mock.MagicMock()
transform_caption = mock.MagicMock()
transform_newlines = mock.MagicMock()
- with mock.patch('nikola.plugins.command.import_wordpress.CommandImportWordpress.transform_sourcecode', transform_sourcecode):
+ with mock.patch('nikola.plugins.command.import_wordpress.CommandImportWordpress.transform_code', transform_code):
with mock.patch('nikola.plugins.command.import_wordpress.CommandImportWordpress.transform_caption', transform_caption):
with mock.patch('nikola.plugins.command.import_wordpress.CommandImportWordpress.transform_multiple_newlines', transform_newlines):
self.import_command.transform_content("random content")
- self.assertTrue(transform_sourcecode.called)
+ self.assertTrue(transform_code.called)
self.assertTrue(transform_caption.called)
self.assertTrue(transform_newlines.called)
@@ -340,21 +325,18 @@ import sys
print sys.version
[/sourcecode]"""
- content = self.import_command.transform_sourcecode(content)
+ content = self.import_command.transform_code(content)
self.assertFalse('[/sourcecode]' in content)
self.assertFalse('[sourcecode language=' in content)
replaced_content = """Hello World.
-
-~~~~~~~~~~~~{.Python}
+```Python
import sys
print sys.version
-~~~~~~~~~~~~
-"""
-
+```"""
self.assertEqual(content, replaced_content)
def test_transform_caption(self):
diff --git a/tests/test_integration.py b/tests/test_integration.py
index 28b2965..62ccd79 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -33,8 +33,8 @@ class EmptyBuildTest(BaseTestCase):
@classmethod
def setUpClass(cls):
"""Setup a demo site."""
- # for tests that need bilingual support override languaje_settings
- cls.languaje_settings()
+ # for tests that need bilingual support override language_settings
+ cls.language_settings()
cls.startdir = os.getcwd()
cls.tmpdir = tempfile.mkdtemp()
cls.target_dir = os.path.join(cls.tmpdir, "target")
@@ -44,7 +44,7 @@ class EmptyBuildTest(BaseTestCase):
cls.build()
@classmethod
- def languaje_settings(cls):
+ def language_settings(cls):
LocaleSupportInTesting.initialize_locales_for_testing("unilingual")
@classmethod
@@ -116,12 +116,12 @@ class DemoBuildTest(EmptyBuildTest):
def test_index_in_sitemap(self):
sitemap_path = os.path.join(self.target_dir, "output", "sitemap.xml")
sitemap_data = io.open(sitemap_path, "r", encoding="utf8").read()
- self.assertTrue('<loc>http://getnikola.com/index.html</loc>' in sitemap_data)
+ self.assertTrue('<loc>https://example.com/index.html</loc>' in sitemap_data)
def test_avoid_double_slash_in_rss(self):
rss_path = os.path.join(self.target_dir, "output", "rss.xml")
rss_data = io.open(rss_path, "r", encoding="utf8").read()
- self.assertFalse('http://getnikola.com//' in rss_data)
+ self.assertFalse('https://example.com//' in rss_data)
class RepeatedPostsSetting(DemoBuildTest):
@@ -193,9 +193,9 @@ class TranslatedBuildTest(EmptyBuildTest):
dataname = "translated_titles"
@classmethod
- def languaje_settings(cls):
+ def language_settings(cls):
LocaleSupportInTesting.initialize_locales_for_testing("bilingual")
- # the other languaje
+ # the other language
cls.ol = LocaleSupportInTesting.langlocales["other"][0]
def test_translated_titles(self):
@@ -272,8 +272,8 @@ class RelativeLinkTest(DemoBuildTest):
conf_path = os.path.join(self.target_dir, "conf.py")
with io.open(conf_path, "r", encoding="utf-8") as inf:
data = inf.read()
- data = data.replace('SITE_URL = "http://getnikola.com/"',
- 'SITE_URL = "http://getnikola.com/foo/bar/"')
+ data = data.replace('SITE_URL = "https://example.com/"',
+ 'SITE_URL = "https://example.com/foo/bar/"')
with io.open(conf_path, "w+", encoding="utf8") as outf:
outf.write(data)
@@ -295,8 +295,8 @@ class RelativeLinkTest(DemoBuildTest):
"""Test that the correct path is in sitemap, and not the wrong one."""
sitemap_path = os.path.join(self.target_dir, "output", "sitemap.xml")
sitemap_data = io.open(sitemap_path, "r", encoding="utf8").read()
- self.assertFalse('<loc>http://getnikola.com/</loc>' in sitemap_data)
- self.assertTrue('<loc>http://getnikola.com/foo/bar/index.html</loc>' in sitemap_data)
+ self.assertFalse('<loc>https://example.com/</loc>' in sitemap_data)
+ self.assertTrue('<loc>https://example.com/foo/bar/index.html</loc>' in sitemap_data)
class TestCheck(DemoBuildTest):
@@ -321,7 +321,7 @@ class TestCheckAbsoluteSubFolder(TestCheck):
"""Validate links in a site which is:
* built in URL_TYPE="absolute"
- * deployable to a subfolder (BASE_URL="http://getnikola.com/foo/")
+ * deployable to a subfolder (BASE_URL="https://example.com/foo/")
"""
@classmethod
@@ -329,8 +329,8 @@ class TestCheckAbsoluteSubFolder(TestCheck):
conf_path = os.path.join(self.target_dir, "conf.py")
with io.open(conf_path, "r", encoding="utf-8") as inf:
data = inf.read()
- data = data.replace('SITE_URL = "http://getnikola.com/"',
- 'SITE_URL = "http://getnikola.com/foo/"')
+ data = data.replace('SITE_URL = "https://example.com/"',
+ 'SITE_URL = "https://example.com/foo/"')
data = data.replace("# URL_TYPE = 'rel_path'",
"URL_TYPE = 'absolute'")
with io.open(conf_path, "w+", encoding="utf8") as outf:
@@ -341,14 +341,14 @@ class TestCheckAbsoluteSubFolder(TestCheck):
"""Test that the correct path is in sitemap, and not the wrong one."""
sitemap_path = os.path.join(self.target_dir, "output", "sitemap.xml")
sitemap_data = io.open(sitemap_path, "r", encoding="utf8").read()
- self.assertTrue('<loc>http://getnikola.com/foo/index.html</loc>' in sitemap_data)
+ self.assertTrue('<loc>https://example.com/foo/index.html</loc>' in sitemap_data)
class TestCheckFullPathSubFolder(TestCheckAbsoluteSubFolder):
"""Validate links in a site which is:
* built in URL_TYPE="full_path"
- * deployable to a subfolder (BASE_URL="http://getnikola.com/foo/")
+ * deployable to a subfolder (BASE_URL="https://example.com/foo/")
"""
@classmethod
@@ -356,8 +356,8 @@ class TestCheckFullPathSubFolder(TestCheckAbsoluteSubFolder):
conf_path = os.path.join(self.target_dir, "conf.py")
with io.open(conf_path, "r", encoding="utf-8") as inf:
data = inf.read()
- data = data.replace('SITE_URL = "http://getnikola.com/"',
- 'SITE_URL = "http://getnikola.com/foo/"')
+ data = data.replace('SITE_URL = "https://example.com/"',
+ 'SITE_URL = "https://example.com/foo/"')
data = data.replace("# URL_TYPE = 'rel_path'",
"URL_TYPE = 'full_path'")
with io.open(conf_path, "w+", encoding="utf8") as outf:
@@ -423,8 +423,8 @@ class RelativeLinkTest2(DemoBuildTest):
"""Test that the correct path is in sitemap, and not the wrong one."""
sitemap_path = os.path.join(self.target_dir, "output", "sitemap.xml")
sitemap_data = io.open(sitemap_path, "r", encoding="utf8").read()
- self.assertFalse('<loc>http://getnikola.com/</loc>' in sitemap_data)
- self.assertTrue('<loc>http://getnikola.com/blog/index.html</loc>' in sitemap_data)
+ self.assertFalse('<loc>https://example.com/</loc>' in sitemap_data)
+ self.assertTrue('<loc>https://example.com/blog/index.html</loc>' in sitemap_data)
class MonthlyArchiveTest(DemoBuildTest):
@@ -447,6 +447,49 @@ class MonthlyArchiveTest(DemoBuildTest):
self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, 'target', 'output', '2012', '03', 'index.html')))
+class DayArchiveTest(DemoBuildTest):
+ """Check that per-day archives build and are correct."""
+
+ @classmethod
+ def patch_site(self):
+ """Set the SITE_URL to have a path"""
+ conf_path = os.path.join(self.target_dir, "conf.py")
+ with io.open(conf_path, "r", encoding="utf-8") as inf:
+ data = inf.read()
+ data = data.replace('# CREATE_DAILY_ARCHIVE = False',
+ 'CREATE_DAILY_ARCHIVE = True')
+ with io.open(conf_path, "w+", encoding="utf8") as outf:
+ outf.write(data)
+ outf.flush()
+
+ def test_day_archive(self):
+ """See that it builds"""
+ self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, 'target', 'output', '2012', '03', '30', 'index.html')))
+
+
+class FullArchiveTest(DemoBuildTest):
+ """Check that full archives build and are correct."""
+
+ @classmethod
+ def patch_site(self):
+ """Set the SITE_URL to have a path"""
+ conf_path = os.path.join(self.target_dir, "conf.py")
+ with io.open(conf_path, "r", encoding="utf-8") as inf:
+ data = inf.read()
+ data = data.replace('# CREATE_FULL_ARCHIVES = False',
+ 'CREATE_FULL_ARCHIVES = True')
+ with io.open(conf_path, "w+", encoding="utf8") as outf:
+ outf.write(data)
+ outf.flush()
+
+ def test_full_archive(self):
+ """See that it builds"""
+ self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, 'target', 'output', 'archive.html')))
+ self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, 'target', 'output', '2012', 'index.html')))
+ self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, 'target', 'output', '2012', '03', 'index.html')))
+ self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, 'target', 'output', '2012', '03', '30', 'index.html')))
+
+
class SubdirRunningTest(DemoBuildTest):
"""Check that running nikola from subdir works."""
@@ -502,5 +545,50 @@ class InvariantBuildTest(EmptyBuildTest):
self.assertEqual(exc.returncode, 0, 'Unexplained diff for the invariance test.')
+class RedirectionsTest1(TestCheck):
+ """Check REDIRECTIONS"""
+
+ @classmethod
+ def patch_site(self):
+ """"""
+ conf_path = os.path.join(self.target_dir, "conf.py")
+ with io.open(conf_path, "a", encoding="utf8") as outf:
+ outf.write("""\n\nREDIRECTIONS = [ ("posts/foo.html", "/foo/bar.html"), ]\n\n""")
+
+ @classmethod
+ def fill_site(self):
+ target_path = os.path.join(self.target_dir, "files", "foo", "bar.html")
+ nikola.utils.makedirs(os.path.join(self.target_dir, "files", "foo"))
+ with io.open(target_path, "w+", encoding="utf8") as outf:
+ outf.write("foo")
+
+class RedirectionsTest2(TestCheck):
+ """Check external REDIRECTIONS"""
+
+ @classmethod
+ def patch_site(self):
+ """"""
+ conf_path = os.path.join(self.target_dir, "conf.py")
+ with io.open(conf_path, "a", encoding="utf8") as outf:
+ outf.write("""\n\nREDIRECTIONS = [ ("foo.html", "http://www.example.com/"), ]\n\n""")
+
+class RedirectionsTest3(TestCheck):
+ """Check relative REDIRECTIONS"""
+
+ @classmethod
+ def patch_site(self):
+ """"""
+ conf_path = os.path.join(self.target_dir, "conf.py")
+ with io.open(conf_path, "a", encoding="utf8") as outf:
+ outf.write("""\n\nREDIRECTIONS = [ ("foo.html", "foo/bar.html"), ]\n\n""")
+
+ @classmethod
+ def fill_site(self):
+ target_path = os.path.join(self.target_dir, "files", "foo", "bar.html")
+ nikola.utils.makedirs(os.path.join(self.target_dir, "files", "foo"))
+ with io.open(target_path, "w+", encoding="utf8") as outf:
+ outf.write("foo")
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/tests/test_rss_feeds.py b/tests/test_rss_feeds.py
index 5eeb570..992b1b7 100644
--- a/tests/test_rss_feeds.py
+++ b/tests/test_rss_feeds.py
@@ -33,6 +33,13 @@ class FakeCompiler(object):
demote_headers = False
compile_html = None
extension = lambda self: '.html'
+ name = "fake"
+
+ def read_metadata(*args, **kwargs):
+ return {}
+
+ def register_extra_dependencies(self, post):
+ pass
class RSSFeedTest(unittest.TestCase):
@@ -42,14 +49,14 @@ class RSSFeedTest(unittest.TestCase):
with mock.patch('nikola.post.get_meta',
mock.Mock(return_value=(
- {'title': 'post title',
+ ({'title': 'post title',
'slug': 'awesome_article',
'date': '2012-10-01 22:41',
'author': None,
'tags': 'tags',
'link': 'link',
'description': 'description',
- 'enclosure': 'http://www.example.org/foo.mp3'}
+ 'enclosure': 'http://www.example.org/foo.mp3'}, True)
))):
with mock.patch('nikola.nikola.utils.os.path.isdir',
mock.Mock(return_value=True)):
diff --git a/tests/test_rst_compiler.py b/tests/test_rst_compiler.py
index 1747332..5bbd617 100644
--- a/tests/test_rst_compiler.py
+++ b/tests/test_rst_compiler.py
@@ -122,8 +122,8 @@ class ReSTExtensionTestCaseTestCase(ReSTExtensionTestCase):
class MathTestCase(ReSTExtensionTestCase):
sample = ':math:`e^{ix} = \cos x + i\sin x`'
- def test_mathjax(self):
- """ Test that math is outputting MathJax."""
+ def test_math(self):
+ """ Test that math is outputting TeX code."""
self.basic_test()
self.assertHTMLContains("span", attributes={"class": "math"},
text="\(e^{ix} = \cos x + i\sin x\)")
diff --git a/tests/test_utils.py b/tests/test_utils.py
index c392c02..1e2d3b3 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -34,7 +34,7 @@ class GetMetaTest(unittest.TestCase):
post.metadata_path = 'file_with_metadata.meta'
with mock.patch('nikola.post.io.open', opener_mock, create=True):
- meta = get_meta(post)
+ meta, nsm = get_meta(post)
self.assertEqual('Nikola needs more tests!', meta['title'])
self.assertEqual('write-tests-now', meta['slug'])
@@ -42,6 +42,7 @@ class GetMetaTest(unittest.TestCase):
self.assertFalse('tags' in meta)
self.assertFalse('link' in meta)
self.assertFalse('description' in meta)
+ self.assertTrue(nsm)
def test_get_title_from_rest(self):
file_metadata = [".. slug: write-tests-now\n",
@@ -60,7 +61,7 @@ class GetMetaTest(unittest.TestCase):
post.metadata_path = 'file_with_metadata.meta'
with mock.patch('nikola.post.io.open', opener_mock, create=True):
- meta = get_meta(post)
+ meta, nsm = get_meta(post)
self.assertEqual('Post Title', meta['title'])
self.assertEqual('write-tests-now', meta['slug'])
@@ -68,6 +69,7 @@ class GetMetaTest(unittest.TestCase):
self.assertFalse('tags' in meta)
self.assertFalse('link' in meta)
self.assertFalse('description' in meta)
+ self.assertTrue(nsm)
def test_get_title_from_fname(self):
file_metadata = [".. slug: write-tests-now\n",
@@ -84,7 +86,7 @@ class GetMetaTest(unittest.TestCase):
post.metadata_path = 'file_with_metadata.meta'
with mock.patch('nikola.post.io.open', opener_mock, create=True):
- meta = get_meta(post, 'file_with_metadata')
+ meta, nsm = get_meta(post, 'file_with_metadata')
self.assertEqual('file_with_metadata', meta['title'])
self.assertEqual('write-tests-now', meta['slug'])
@@ -92,6 +94,7 @@ class GetMetaTest(unittest.TestCase):
self.assertFalse('tags' in meta)
self.assertFalse('link' in meta)
self.assertFalse('description' in meta)
+ self.assertTrue(nsm)
def test_use_filename_as_slug_fallback(self):
file_metadata = [".. title: Nikola needs more tests!\n",
@@ -109,7 +112,7 @@ class GetMetaTest(unittest.TestCase):
post.metadata_path = 'Slugify this.meta'
with mock.patch('nikola.post.io.open', opener_mock, create=True):
- meta = get_meta(post, 'Slugify this')
+ meta, nsm = get_meta(post, 'Slugify this')
self.assertEqual('Nikola needs more tests!', meta['title'])
self.assertEqual('slugify-this', meta['slug'])
@@ -117,13 +120,14 @@ class GetMetaTest(unittest.TestCase):
self.assertFalse('tags' in meta)
self.assertFalse('link' in meta)
self.assertFalse('description' in meta)
+ self.assertTrue(nsm)
def test_extracting_metadata_from_filename(self):
post = dummy()
post.source_path = '2013-01-23-the_slug-dubdubtitle.md'
post.metadata_path = '2013-01-23-the_slug-dubdubtitle.meta'
with mock.patch('nikola.post.io.open', create=True):
- meta = get_meta(
+ meta, _ = get_meta(
post,
'(?P<date>\d{4}-\d{2}-\d{2})-(?P<slug>.*)-(?P<title>.*)\.md')
@@ -136,7 +140,7 @@ class GetMetaTest(unittest.TestCase):
post.source_path = 'some/path/the_slug.md'
post.metadata_path = 'some/path/the_slug.meta'
with mock.patch('nikola.post.io.open', create=True):
- meta = get_meta(post)
+ meta, _ = get_meta(post)
self.assertEqual('the_slug', meta['slug'])
@@ -246,7 +250,7 @@ class TranslatableSettingsTest(unittest.TestCase):
except NameError: # Python 3
u = str(S)
- cn = S() #   no language specified
+ cn = S() # no language specified
cr = S('xx') # real language specified
cf = S('zz') # fake language specified