Files
poona-ams/backend/tests/test_task8_delivery.py
T

42 lines
1.8 KiB
Python

import subprocess
import zipfile
from pathlib import Path
def test_package_target_creates_clean_delivery_zip(tmp_path):
repo_root = Path(__file__).resolve().parent.parent.parent
zip_path = tmp_path / "poona-ams-delivery.zip"
# Run git archive command (matching Makefile package target)
cmd = ["git", "archive", "--format=zip", f"--output={zip_path}", "HEAD"]
res = subprocess.run(cmd, cwd=repo_root, capture_output=True, text=True)
assert res.returncode == 0, f"git archive failed: {res.stderr}"
assert zip_path.exists()
with zipfile.ZipFile(zip_path, "r") as z:
names = z.namelist()
assert len(names) > 0
# Assert no .db database files
db_files = [n for n in names if n.endswith(".db") or n.endswith(".sqlite") or n.endswith(".sqlite3")]
assert db_files == [], f"Delivery archive must not contain SQLite databases: {db_files}"
# Assert no frontend dist/ build files
dist_files = [n for n in names if "dist/" in n or n.startswith("dist/")]
assert dist_files == [], f"Delivery archive must not contain dist/ directory: {dist_files}"
# Assert no __pycache__ or compiled bytecode
pycache_files = [n for n in names if "__pycache__" in n or n.endswith(".pyc")]
assert pycache_files == [], f"Delivery archive must not contain __pycache__: {pycache_files}"
# Assert no node_modules or .venv
vendor_files = [n for n in names if "node_modules/" in n or ".venv/" in n]
assert vendor_files == [], f"Delivery archive must not contain vendor/env files: {vendor_files}"
# Assert essential source files are included
assert "backend/app/main.py" in names
assert "frontend/src/App.tsx" in names
assert "Makefile" in names
assert "README.md" in names
assert ".gitignore" in names