spb/traite-evaluation-qc
Public
1import pytest, numpy as np2from traite import cas3, finance as fin34def test_cas3_identites():5 r = cas3.tout(); b = r["base"]; p = r["projection"]; h = r["hyp"]6 assert b["rbe"] == pytest.approx(b["rbp_contrat"] * (1 - b["taux_vacance_pertes"]) + b["autres_revenus"])7 assert b["rne"] == pytest.approx(b["rbe"] - b["depenses_totales"])8 assert len(p) == h["horizon_ans"] + 1 and (p["rne"] > 0).all()9 assert p.loc[0, "rne"] == pytest.approx(b["rne"], rel=1e-9) # année 1 = RNE normalisé10 assert (p["rbp"].diff().dropna() > 0).all() # loyers croissants11 assert (p["rbp"] <= p["rbp_marche"] + 1e-6).all() # jamais au-dessus du marché12 d = r["dcf"]; flux = d["flux"]13 va = sum(cf / (1 + h["taux_actualisation"]) ** (t + 1) for t, cf in enumerate(flux)) + d["vt_nette"] / (1 + h["taux_actualisation"]) ** h["horizon_ans"]14 assert d["valeur"] == pytest.approx(va)15 assert d["vt_brute"] == pytest.approx(d["rne_T1"] / h["taux_terminal"]) and d["vt_nette"] == pytest.approx(d["vt_brute"] * (1 - h["couts_vente"]))16 f = r["financement"]17 assert f["rcd"] >= h["financement"]["rcd_min"] - 1e-9 and f["rpv"] <= h["financement"]["rpv"] + 1e-918 assert 0.03 < r["taux"]["mediane"] < 0.07 and r["taux"]["n"] >= 1019 assert 0.5 < r["valeur_capitalisation"] / d["valeur"] < 1.520