Beispiel #1
0
    def setUp(self):
        self.site = build_test_site()
        self.compiler = Compiler(site=self.site, output_path=os.path.join(TEST_SITE, "output"))

        if HERE not in self.compiler.output_path:
            sys.exit("Something is terribly wrong. {}, {}".format(HERE, self.compiler.output_path))

        if os.path.exists(self.compiler.output_path):
            shutil.rmtree(self.compiler.output_path)
Beispiel #2
0
class TestCompiler(TestCase):

    def setUp(self):
        self.site = build_test_site()
        self.compiler = Compiler(site=self.site, output_path=os.path.join(TEST_SITE, "output"))

        if HERE not in self.compiler.output_path:
            sys.exit("Something is terribly wrong. {}, {}".format(HERE, self.compiler.output_path))

        if os.path.exists(self.compiler.output_path):
            shutil.rmtree(self.compiler.output_path)

    def test_routing(self):
        """Ensures that compilation results are routed properly."""
        self.site.route(r"(.*)", lambda match, item: "{}/index.html".format(os.path.splitext(match.group(1))[0]))
        self.site.route(r"index", lambda match, item: "index.html")
        self.compiler.compile()

        output = self.compiler.output_path
        self.assertTrue(os.path.exists(os.path.join(output)))
        self.assertTrue(os.path.exists(os.path.join(output, "index.html")))
        self.assertTrue(os.path.exists(os.path.join(output, "test", "index.html")))
        self.assertTrue(os.path.exists(os.path.join(output, "test", "test", "index.html")))
        self.assertTrue(os.path.exists(os.path.join(output, "test", "test", "test", "index.html")))