SPB Git
1.6 KB · 25 lines python
1import json, pathlib, pandas as pd, numpy as np2from traite import synth3ROOT = pathlib.Path(__file__).resolve().parents[3]45def test_generation_deterministe(tmp_path, monkeypatch):6    monkeypatch.setattr(synth, "OUT", tmp_path)7    a = synth.ecrire_tout(); b = synth.ecrire_tout()8    pd.testing.assert_frame_equal(a["cas1"]["ventes"], b["cas1"]["ventes"])9    pd.testing.assert_frame_equal(a["cas3"]["comparables"], b["cas3"]["comparables"])10    assert (tmp_path / "README.md").exists() and (tmp_path / "calibration_journal.csv").exists()1112def test_coherence_interne():13    v = pd.read_csv(ROOT / "data/synthetic/cas1_gatineau_ventes.csv")14    assert (v.prix_vente > 50_000).all() and (v.superficie_habitable_m2 > 40).all() and v.id_vente.is_unique15    q = pd.read_csv(ROOT / "data/synthetic/cas2_quebec_ventes_plex.csv")16    assert np.allclose(q.taux_global, (q.rne / q.prix_vente).round(4)) and np.allclose(q.mrb, (q.prix_vente / q.revenu_brut_potentiel).round(2))17    m = pd.read_csv(ROOT / "data/synthetic/cas3_montreal_comparables.csv")18    assert m.taux_global.between(0.025, 0.09).all()19    e = pd.read_csv(ROOT / "data/synthetic/cas3_montreal_etat_locatif.csv")20    assert len(e) == 12 and (e.loyer_mensuel_contrat <= e.loyer_mensuel_marche + 1).all()21    c = pd.read_csv(ROOT / "data/synthetic/cas1_gatineau_couts.csv")22    assert np.allclose(c.montant, (c.quantite * c.prix_unitaire).round(2))23    p = pd.read_csv(ROOT / "data/synthetic/cas4_portefeuille.csv"); s = pd.read_csv(ROOT / "data/synthetic/cas4_portefeuille_series.csv")24    assert set(p.id_immeuble) == set(s.id_immeuble) and (p.dette <= p.valeur_2026).all()25
Files · 317d87e96c9fbe3102824f20418c9f14e795f254
Menu

Theme