import pytest, numpy as np from traite import cas2, cas4 def test_cas2(): r = cas2.tout(); b = r["base"] assert b["rbe"] == pytest.approx(b["rbp_contrat"] * (1 - 0.03)) and b["rne"] == pytest.approx(b["rbe"] - b["depenses_totales"]) assert r["indicateurs"]["n"] >= 30 and 0.02 < r["indicateurs"]["taux_median"] < 0.07 assert 300_000 < r["valeur_capitalisation"] < 1_500_000 and 300_000 < r["valeur_mrb"] < 1_500_000 def test_cas4(): r = cas4.tout(); s = r["sommaire"] assert s["total"]["n"] == 48 and abs(s["par_rmr"]["valeur"].sum() - s["total"]["valeur"]) < 1 assert 0 < s["total"]["rpv"] < 1 assert len(r["croissance"]) == 48 and r["croissance"]["croissance_annuelle"].between(-0.05, 0.12).all() e = r["effets"]; assert e.loc["inondable", "coef"] > 0 and e.loc["rmr_Saguenay", "coef"] > e.loc["rmr_Québec", "coef"] > 0