50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import shutil
|
|
import subprocess
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
|
|
REPO = Path(__file__).resolve().parents[2]
|
|
MIGRATION_PACKAGE_PREFIX = "trex_core/adapters/persistence/sql/"
|
|
|
|
|
|
def test_built_wheel_contains_exact_canonical_migration_inventory(tmp_path: Path):
|
|
source = tmp_path / "source"
|
|
source.mkdir()
|
|
shutil.copy2(REPO / "pyproject.toml", source / "pyproject.toml")
|
|
shutil.copytree(REPO / "trex_core", source / "trex_core")
|
|
output = tmp_path / "dist"
|
|
|
|
subprocess.run(
|
|
[
|
|
"uv",
|
|
"build",
|
|
"--wheel",
|
|
"--no-build-logs",
|
|
"--no-create-gitignore",
|
|
"--out-dir",
|
|
str(output),
|
|
str(source),
|
|
],
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
|
|
wheels = list(output.glob("*.whl"))
|
|
assert len(wheels) == 1
|
|
expected = sorted(
|
|
path.relative_to(REPO).as_posix()
|
|
for path in (REPO / MIGRATION_PACKAGE_PREFIX).glob("*.sql")
|
|
)
|
|
assert expected
|
|
with zipfile.ZipFile(wheels[0]) as wheel:
|
|
actual = sorted(
|
|
name
|
|
for name in wheel.namelist()
|
|
if name.startswith(MIGRATION_PACKAGE_PREFIX) and name.endswith(".sql")
|
|
)
|
|
assert actual == expected
|