Files
omicron-ssg/tests/unit/test_output.py
T

39 lines
1.1 KiB
Python

from pathlib import Path
import pytest
from omicron.ssg.output.file import File
from omicron.ssg.output.output import OutputError
def test_absolute_destination_raises(make_site, tmp_path):
site = make_site("thin_site")
with pytest.raises(OutputError):
File(site, Path("/copy.txt"), tmp_path / "source.txt")
def test_non_normalized_destination_raises(make_site, tmp_path):
site = make_site("thin_site")
with pytest.raises(OutputError):
File(site, Path("assets/../copy.txt"), tmp_path / "source.txt")
def test_site_raises_after_garbage_collection(make_site, tmp_path):
site = make_site("thin_site")
file = File(site, Path("copy.txt"), tmp_path / "source.txt")
del site
with pytest.raises(ReferenceError):
file.site
def test_url(make_site, tmp_path):
site = make_site("thin_site")
file = File(site, Path("assets/copy.txt"), tmp_path / "source.txt")
assert file.url == "/assets/copy.txt"
def test_url_strips_index_html(make_site, tmp_path):
site = make_site("thin_site")
file = File(site, Path("posts/index.html"), tmp_path / "source.txt")
assert file.url == "/posts"