32 lines
803 B
Python
32 lines
803 B
Python
import shutil
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
MAIN_SITE = Path(__file__).parent.parent / "data" / "sites" / "main"
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def built_site(tmp_path_factory):
|
|
site_dir = tmp_path_factory.mktemp("main")
|
|
shutil.copytree(
|
|
MAIN_SITE,
|
|
site_dir,
|
|
dirs_exist_ok=True,
|
|
ignore=shutil.ignore_patterns("output", "build.log"),
|
|
)
|
|
result = subprocess.run(
|
|
["ossg", "--site", str(site_dir), "build"],
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
assert result.returncode == 0, result.stderr
|
|
return site_dir / "output"
|
|
|
|
|
|
def test_article_renders(built_site):
|
|
output = built_site / "posts" / "first-post" / "index.html"
|
|
assert output.exists()
|
|
assert "First Post" in output.read_text()
|