2025-11-30 14:45:55 +01:00
|
|
|
"""Tests to ensure website stays within size budget."""
|
|
|
|
|
|
2025-09-07 21:26:55 +02:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
# Budget for the entire website (single file) in bytes
|
|
|
|
|
BUDGET = 14 * 1024 # 14 KiB
|
|
|
|
|
|
|
|
|
|
HERE = os.path.dirname(__file__)
|
2025-11-30 13:42:16 +01:00
|
|
|
SITE_FILE = os.path.join(HERE, "index.html")
|
2025-09-07 21:26:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_site_file_exists():
|
2025-11-30 14:45:55 +01:00
|
|
|
"""Verify the main site HTML file exists."""
|
2025-09-07 21:26:55 +02:00
|
|
|
assert os.path.exists(SITE_FILE), f"Missing site file: {SITE_FILE}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_site_size_under_budget():
|
2025-11-30 14:45:55 +01:00
|
|
|
"""Verify site size is under the defined budget."""
|
2025-09-07 21:26:55 +02:00
|
|
|
size = os.path.getsize(SITE_FILE)
|
|
|
|
|
assert size <= BUDGET, f"Site size {size} bytes exceeds budget {BUDGET}"
|