SPB Git
2.1 KB · 40 lines python
1import pytest2from traite import cout as c34def test_cout_neuf_conventions():5    a = c.cout_neuf(1_000_000, 0.12, 0.10, "direct+indirect")6    assert a["indirects"] == 120_000 and a["incitatif"] == pytest.approx(112_000) and a["total"] == pytest.approx(1_232_000)7    b = c.cout_neuf(1_000_000, 0.12, 0.10, "direct")8    assert b["incitatif"] == 100_000910def test_indexation_et_taille():11    assert c.indexer_cout(1000, 100, 125) == 125012    # élasticité −0,1 : doubler la superficie réduit le coût unitaire de ~6,7 %13    assert c.cout_par_superficie_ajuste(2000, 150, 300, -0.1) == pytest.approx(2000 * 2 ** -0.1)1415def test_age_vie_bornes():16    assert c.depreciation_age_vie(500_000, 15, 60) == 125_00017    assert c.depreciation_age_vie(500_000, 90, 60) == 500_00018    m = c.depreciation_age_vie_modifiee(500_000, 20_000, 15, 60)19    assert m["total"] == pytest.approx(20_000 + 480_000 * 0.25)2021def test_ventilee_sans_double_comptage():22    comps = [c.Composante("toiture", 30_000, 10, 20), c.Composante("chauffage", 20_000, 5, 20)]23    d = c.depreciation_ventilee(500_000, 10_000, comps, 20, 70)24    assert d["courte_duree"]["toiture"] == 15_000 and d["courte_duree"]["chauffage"] == 5_00025    assert d["base_longue"] == 500_000 - 10_000 - 50_00026    assert d["total"] == pytest.approx(10_000 + 20_000 + 440_000 * 20 / 70)2728def test_desuetudes():29    assert c.desuetude_fonctionnelle_curable(12_000, 8_000, 1_000) == 3_00030    assert c.desuetude_incurable_par_loyer(150, 120) == 18_00031    assert c.desuetude_incurable_par_rne(6_000, 0.06, 0.8) == pytest.approx(80_000)32    assert c.desuetude_externe_ventes_appariees(500_000, 470_000, 0.75) == 22_5003334def test_extraction_marche_et_valeur():35    e = c.extraction_depreciation_marche(520_000, 150_000, 480_000, 20)36    assert e["depreciation"] == 110_000 and e["taux"] == pytest.approx(110_000 / 480_000) and e["taux_annuel"] == pytest.approx(110_000 / 480_000 / 20)37    v = c.valeur_par_cout(150_000, 480_000, 80_000, 10_000, 20_000, 15_000)38    assert v["valeur"] == 150_000 + 480_000 - 110_000 + 15_00039    assert v["taux_depreciation"] == pytest.approx(110_000 / 480_000)40
Files · 5e249f74fe4f0fec4e3181288910d4b9478a1a20
Menu

Theme