feat: consolidate legacy workflows into gyxx-flow
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
MODULE_ROOT = PROJECT_ROOT / "src" / "gyxx_flow" / "modules"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("module", "forbidden"),
|
||||
[
|
||||
("content_marketing", 'Path("data") / "v2_results"'),
|
||||
("product_commerce", 'Path("data/logs")'),
|
||||
("product_commerce", 'SCRIPT_DIR / "data"'),
|
||||
("product_commerce", 'PROJECT_ROOT / "debug"'),
|
||||
("product_commerce", "relative_to(PROJECT_ROOT)"),
|
||||
("shop_intelligence", 'os.path.join(os.getcwd(), "debug"'),
|
||||
("supply_chain", 'PACKAGE_ROOT / "shared-data"'),
|
||||
("supply_chain", "~/Downloads/停产产品.xlsx"),
|
||||
],
|
||||
)
|
||||
def test_migrated_runtimes_have_no_known_mutable_output_bypasses(
|
||||
module: str, forbidden: str
|
||||
) -> None:
|
||||
offenders = []
|
||||
for path in (MODULE_ROOT / module / "runtime").rglob("*.py"):
|
||||
source = path.read_text(encoding="utf-8-sig")
|
||||
if forbidden in source:
|
||||
offenders.append(path.relative_to(PROJECT_ROOT).as_posix())
|
||||
|
||||
assert offenders == [], f"{forbidden!r} bypasses the canonical data boundary"
|
||||
|
||||
|
||||
def test_runtime_path_modules_do_not_use_source_local_data_fallbacks() -> None:
|
||||
path_files = [
|
||||
MODULE_ROOT / "content_marketing" / "runtime" / "runtime_paths.py",
|
||||
MODULE_ROOT / "product_commerce" / "runtime" / "runtime_paths.py",
|
||||
MODULE_ROOT / "shop_intelligence" / "runtime" / "paths.py",
|
||||
MODULE_ROOT / "supply_chain" / "runtime" / "paths.py",
|
||||
]
|
||||
forbidden = ('MODULE_ROOT / ".runtime-data"', 'module_root / "var"', 'PROJECT_ROOT / "data"')
|
||||
|
||||
for path in path_files:
|
||||
source = path.read_text(encoding="utf-8-sig")
|
||||
assert not any(pattern in source for pattern in forbidden), path
|
||||
Reference in New Issue
Block a user