def test_baking(self):
        """Test that we can bake pages."""

        with tempfile.TemporaryDirectory() as outdir:
            storage = FileSystemStorage(location=outdir)
            bake(outdir)
            # We should have index.html, about/index.html, subdir/index.html
            EXPECTED_FILES = [
                'index.html',
                'about.html',
                'subdir/index.html',
            ]
            EXPECTED_SLUGS = [
                '',
                'about',
                'subdir/',
            ]
            self.assertEqual(
                set(EXPECTED_FILES),
                set(utils.get_files(storage)),
            )

            for fname, slug in zip(EXPECTED_FILES, EXPECTED_SLUGS):
                with open(
                    os.path.join(outdir, fname),
                    'rb',
                ) as fp:
                    self.assertEqual(
                        b'slug=' + slug.encode('utf-8'),
                        fp.read().strip(),
                    )
Ejemplo n.º 2
0
    def test_baking(self):
        """Test that we can bake pages."""

        with tempfile.TemporaryDirectory() as outdir:
            storage = FileSystemStorage(location=outdir)
            bake(outdir)
            # We should have various.
            EXPECTED_FILES = {
                'blog/index.html',
                'blog/p2/index.html',
                'blog/2016/index.html',
                'blog/2016/p2/index.html',
                'blog/2016/05/index.html',
                'blog/2016/06/index.html',
                'blog/2016/07/index.html',
                'blog/2016/05/21/index.html',
                'blog/2016/06/21/index.html',
                'blog/2016/07/21/index.html',
                'blog/2016/05/21/single-post.html',
                'blog/2016/06/21/single-post.html',
                'blog/2016/07/21/single-post.html',
                'blog/2016/05/21/second-post.html',
                'blog/2016/06/21/second-post.html',
                'blog/2016/07/21/second-post.html',
                'blog/2016/05/21/third-post.html',
                'blog/2016/06/21/third-post.html',
                'blog/2016/07/21/third-post.html',
                'blog/2016/05/21/fourth-post.html',
                'blog/2016/06/21/fourth-post.html',
                'blog/2016/07/21/fourth-post.html',
                'blog/2016/05/21/fifth-post.html',
                'blog/2016/06/21/fifth-post.html',
                'blog/2016/07/21/fifth-post.html',
                'blog/index.atom',
                'blog/drafts/draft-post.html',
                'blog/drafts/second-draft-post.html',
            }
            self.assertEqual(
                EXPECTED_FILES,
                set(utils.get_files(storage)),
            )