1"""End-to-end pipeline test on the clearly labelled synthetic fixture."""2import json3import os4import shutil5from pathlib import Path67import pytest8910def test_pipeline_on_synthetic(tmp_path, monkeypatch):11 from ucml import synthetic12 db = synthetic.make(tmp_path / "synthetic" / "autoka-synthetic.db", n_listings=1500)13 monkeypatch.setenv("UCML_ROOT", str(tmp_path))14 monkeypatch.setenv("UCML_SNAPSHOT", str(db))15 import importlib16 from ucml import config17 importlib.reload(config)18 from ucml import ingest, cleaning19 importlib.reload(ingest); importlib.reload(cleaning)20 (tmp_path / "data" / "raw" / "registry").mkdir(parents=True)21 real_reg = Path(__file__).resolve().parents[1] / "data" / "raw" / "registry"22 srcs = {"_comment": "synthetic", "sources": [{"id": f"synthdealer{i:02d}", "name": f"D{i}", "type": "direct", "region": "Montréal"} for i in range(20)]23 + [{"id": "otogo", "name": "Otogo", "type": "portail"}]}24 (tmp_path / "data" / "raw" / "registry" / "sources.json").write_text(json.dumps(srcs))25 (tmp_path / "data" / "raw" / "registry" / "villes_gps.json").write_text(json.dumps({"ville": [45.5, -73.6]}))26 m = ingest.run(snapshot=db, outdir=tmp_path / "data" / "interim", with_hash=False)27 assert m["rows"]["vehicles"] == 150028 importlib.reload(config)29 stats = cleaning.run(interim=tmp_path / "data" / "interim", out=tmp_path / "data" / "processed", registry=tmp_path / "data" / "raw" / "registry")30 assert stats["S0"] == 150031 assert stats["S1_hedonic"] > 100032 assert (tmp_path / "data" / "processed" / "exclusions.csv").exists()33 assert (tmp_path / "data" / "processed" / "price_events.parquet").exists()34