Set up e2e testing

This commit is contained in:
2026-08-28 01:44:38 +02:00
parent 6afc8585db
commit 82f60f3d75
4 changed files with 46 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
name: Main Test Site
base_url: http://127.0.0.1:8000
template: plain
@@ -0,0 +1,10 @@
---
type: article
section: posts
slug: first-post
title: First Post
date: 2026-08-28
tags: [meta]
---
Welcome to the test site. This site will contain some test content for the
static site generator, the content won't matter a lot.
+31
View File
@@ -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()