File: test_load.py

package info (click to toggle)
staticsite 2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 14,648 kB
  • sloc: javascript: 33,722; python: 9,851; makefile: 46; sh: 4
file content (52 lines) | stat: -rw-r--r-- 1,615 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from __future__ import annotations

from unittest import TestCase

from . import utils as test_utils


class TestLoad(test_utils.MockSiteTestMixin, TestCase):
    def test_leaf_nodes(self):
        """
        Test that empty leaf nodes are pruned
        """
        files = {
            "index.md": {},
            "drafts/index.md": {"date": "2040-01-01"},
            "skipped/.staticsite": {"skip": True},
            "dir1/dir2/skipped/.staticsite": {"skip": True},
            "dir3/dir4/drafts/index.md": {"date": "2040-01-01"},
            "empty/.gitignore": "",
            "dir5/dir6/empty/.gitignore": "",
        }
        with self.site(files) as mocksite:
            mocksite.assertPagePaths(("",))

    def test_ignore(self):
        files = {
            "index.md": {},
            "index.md.swp": {},
            "index.md~": {},
            ".staticsite": {
                "dirs": {"assets": {"asset": True}},
                "ignore": ["*.swp", "*~"],
            },
            "drafts/index.md": {},
            "drafts/index.md~": {},
            "drafts/index.md.swp": {},
            "assets/file.txt": "",
            "assets/file.txt.swp": "",
            "assets/file.txt~": "",
            "assets/sub/file1.txt": "",
            "assets/sub/file1.txt.swp": "",
            "assets/sub/file1.txt~": "",
        }
        with self.site(files) as mocksite:
            mocksite.assertPagePaths(
                (
                    "",
                    "drafts",
                    "assets/file.txt",
                    "assets/sub/file1.txt",
                )
            )