Set up e2e testing
This commit is contained in:
@@ -4,3 +4,5 @@ __pycache__
|
||||
*.pyc
|
||||
.coverage
|
||||
htmlcov/
|
||||
tests/data/sites/*/output/
|
||||
tests/data/sites/*/build.log
|
||||
|
||||
@@ -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.
|
||||
@@ -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