Skip to content

Commit

Permalink
make redirectio tests actually test redirections, 1 failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Jun 2, 2015
1 parent d15ce70 commit cd4198c
Showing 1 changed file with 45 additions and 44 deletions.
89 changes: 45 additions & 44 deletions tests/test_integration.py
Expand Up @@ -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."""

Expand Down Expand Up @@ -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.