SPB Git forge

spb/uqo-chat

Public
14commits 1branches 0releases
1.4 MBsize
maindefault branch
17 days agolast push
Python 64.6% TypeScript 33.7% CSS 0.8%
2.2 KB · 44 lines python
Raw Blame History
1import io23from openpyxl import load_workbook45from app.tools.create_excel import build_workbook6from app.tools.excel_templates import TEMPLATES789def _ws(params):  # noqa: ANN001, ANN20210    data, _ = build_workbook(TEMPLATES["comparables_ajustes"](params))11    return load_workbook(io.BytesIO(data))["Comparables"]121314def test_rates_mode_builds_live_formulas() -> None:15    ws = _ws({16        "sujet": {"adresse": "Bungalow Hull", "superficie": "1 200 pi²", "terrain": 6000, "garage": "Oui", "etat": "bon"},17        "taux": {"superficie": "120 $", "terrain": 8, "garage": "15 000 $", "etat": 10000},18        "taux_temps_mensuel": "0,5 %",19        "comparables": [20            {"adresse": "45 rue Laurier", "prix": "425 000 $", "date": "mars 2026", "mois": 6, "superficie": 1150,21             "terrain": 5500, "garage": "Oui", "etat": "bon"},22            {"adresse": "12 rue Front", "prix": 398000, "mois": 8, "superficie": 1250, "terrain": 7000,23             "garage": "Non", "etat": "moyen"},24        ],25    })26    values = {c.coordinate: c.value for row in ws.iter_rows() for c in row if c.value is not None}27    # subject inputs and rates present as blue inputs28    assert values["B4"] == 1200 and values["D4"] == 12029    assert any(v == "Oui".lower() or v == 1.0 for k, v in values.items() if k.startswith("B"))  # garage → 130    # adjustment formulas reference subject/rate cells31    formulas = [v for v in values.values() if isinstance(v, str) and v.startswith("=(")]32    assert formulas and all("$B$" in f and "$D$" in f for f in formulas)33    # time adjustment uses months × monthly rate34    assert any(isinstance(v, str) and v.startswith("=D") and "*$D$" in v for v in values.values())35    assert any(h == "Ajust. Garage ($)" for h in values.values())36    assert any(h == "Médiane" for h in values.values())373839def test_dollar_mode_still_works_with_text() -> None:40    ws = _ws({"comparables": [{"adresse": "A", "prix": 415000, "temps": "+2 %", "garage": "Oui",41                               "ajustements": {"Superficie": -5000}}]})42    values = [c.value for row in ws.iter_rows() for c in row if c.value is not None]43    assert "Oui" in values and -5000 in values and "Garage" in values44