test_project

tests/test_project.py
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
import inspect
from pathlib import Path

from lektor_ng.project import Project


def test_Project_get_output_path(tmp_path: Path) -> None:
    project_file = tmp_path / "test.lektorproject"
    project_file.touch()
    project = Project.from_file(project_file)
    assert Path(project.get_output_path()).parts[-2:] == ("builds", project.id)


def test_Project_get_output_path_is_relative_to_project_file(tmp_path: Path) -> None:
    tree = tmp_path / "tree"
    tree.mkdir()
    project_file = tmp_path / "test.lektorproject"
    project_file.write_text(
        inspect.cleandoc(
            """[project]
            path = tree
            output_path = htdocs
            """
        )
    )

    project = Project.from_file(project_file)
    assert project.get_output_path() == str(tmp_path / "htdocs")