Skip to content
Permalink
Browse files

make redirectio tests actually test redirections, 1 failure

  • Loading branch information
ralsina committed Jun 2, 2015
1 parent d15ce70 commit cd4198c8c6823ff4d08b203a07996038f47bb7f2
Showing with 45 additions and 44 deletions.
  1. +45 −44 tests/test_integration.py
@@ -232,50 +232,6 @@ def patch_site(self):
outf.write(data)


class RedirectionsTest1(EmptyBuildTest):
"""Check REDIRECTS"""

@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\nREDIRECTS = [ ("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(EmptyBuildTest):
"""Check external REDIRECTS"""

@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\nREDIRECTS = [ ("foo.html", "http://www.example.com/"), ]\n\n""")

class RedirectionsTest3(EmptyBuildTest):
"""Check relative REDIRECTS"""

@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\nREDIRECTS = [ ("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 MissingDefaultLanguageTest(TranslatedBuildTest):
"""Make sure posts only in secondary languages work."""

@@ -589,5 +545,50 @@ def test_invariance(self):
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()

0 comments on commit cd4198c

Please sign in to comment.