1import datetime as dt2from ucml import cleaning as cl34def test_powertrain_rules():5 assert cl.powertrain("Hybride rechargeable", None, None, None) == "PHEV"6 assert cl.powertrain("Hybride", None, None, None) == "HEV"7 assert cl.powertrain("Électrique", None, None, None) == "BEV"8 assert cl.powertrain("Essence", None, None, None) == "ICE"9 assert cl.powertrain("Diesel", None, None, None) == "Diesel"10 assert cl.powertrain("", "", "Model 3 2022", "Tesla") == "BEV"11 assert cl.powertrain("", "", "Civic 2019", "Honda") == "unknown"1213def test_body_segment():14 assert cl.body_segment("VUS") == "SUV"15 assert cl.body_segment("Sport Utility") == "SUV"16 assert cl.body_segment("Camionnette") == "Pickup"17 assert cl.body_segment("Berline") == "Sedan"18 assert cl.body_segment("N/D") is None19 assert cl.body_segment("") is None2021def test_vehicle_age():22 t = dt.datetime(2026, 10, 1, tzinfo=dt.timezone.utc).timestamp()23 assert abs(cl.vehicle_age_years(t, 2026) - 1.0) < 0.0124 assert cl.vehicle_age_years(t, 2027) == 0.02526def test_source_class():27 assert cl.source_class("autotrader") == "sampled_portal"28 assert cl.source_class("otogo") == "full_portal"29 assert cl.source_class("kijiji") == "private_marketplace"30 assert cl.source_class("someDealer") == "direct_dealer"31