Files

29 lines
921 B
Python

import fnmatch
import re
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def copied_sources():
sources = []
for line in (ROOT / "Dockerfile").read_text().splitlines():
match = re.match(r"^COPY\s+(.+)\s+\S+$", line.strip())
if match:
sources += match.group(1).split()
return sources
def test_dockerfile_copies_every_top_level_module():
"""A new view module must reach the image without anyone editing the Dockerfile."""
sources = copied_sources()
missing = [p.name for p in ROOT.glob("*.py") if not any(fnmatch.fnmatch(p.name, s) for s in sources)]
assert missing == []
def test_dockerignore_keeps_dev_files_out_of_the_image_but_not_assets():
ignored = (ROOT / ".dockerignore").read_text().split()
for name in (".venv", ".git", "tests", "docs", ".superpowers"):
assert name in ignored
assert "assets" not in ignored