Set up e2e testing
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user