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
|
import inspect
import pytest
from lektor_ng.environment.config import Config
def test_custom_attachment_types(env):
attachment_types = env.load_config().values["ATTACHMENT_TYPES"]
assert attachment_types[".foo"] == "text"
@pytest.fixture(scope="function")
def config(tmp_path, project_url):
projectfile = tmp_path / "scratch.lektorproject"
projectfile.write_text(
inspect.cleandoc(
f"""
[project]
url = {project_url}
"""
)
)
return Config(projectfile)
@pytest.mark.parametrize(
"project_url, expected",
[
("", None),
("/path/", None),
("https://example.org", "https://example.org/"),
],
)
def test_base_url(config, expected):
assert config.base_url == expected
@pytest.mark.parametrize(
"project_url, expected",
[
("", "/"),
("/path", "/path/"),
("/path/", "/path/"),
("https://example.org", "/"),
("https://example.org/pth", "/pth/"),
],
)
def test_base_path(config, expected):
assert config.base_path == expected
|