2026-03-18 22:54:45 +01:00
|
|
|
"""Tests to ensure website stays within size budget."""
|
|
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
# Budget for the entire website (single file) in bytes
|
|
|
|
|
BUDGET = 14 * 1024 # 14 KiB
|
|
|
|
|
|
2026-03-21 17:51:36 +01:00
|
|
|
HERE = Path(__file__).parent.parent
|
2026-03-18 22:54:45 +01:00
|
|
|
SITE_FILE = HERE / "index.html"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_site_file_exists() -> None:
|
|
|
|
|
"""Verify the main site HTML file exists."""
|
|
|
|
|
assert SITE_FILE.exists(), f"Missing site file: {SITE_FILE}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_site_size_under_budget() -> None:
|
|
|
|
|
"""Verify site size is under the defined budget."""
|
|
|
|
|
size = SITE_FILE.stat().st_size
|
|
|
|
|
assert size <= BUDGET, f"Site size {size} bytes exceeds budget {BUDGET}"
|