Corrige les liens mobiles et invalide les previsions contaminees
This commit is contained in:
12
tests/test_forecast_lock.py
Normal file
12
tests/test_forecast_lock.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import forecast
|
||||
|
||||
|
||||
def test_contaminated_forecasts_are_never_read(monkeypatch):
|
||||
def forbidden(*args, **kwargs):
|
||||
raise AssertionError("Une ancienne prévision ne doit jamais être consultée")
|
||||
monkeypatch.setattr(forecast.storage, "forecast_latest", forbidden)
|
||||
for fuel in ("Gazole", "SP95", "SP98", "E10", "E85", "GPLc"):
|
||||
result = forecast.outlook(fuel)
|
||||
assert result["status"] == "insufficient"
|
||||
assert "fuite de cible" in result["reason"]
|
||||
assert "Aucun signal prédictif" in result["reason"]
|
||||
@@ -166,7 +166,7 @@ def test_samples_carry_cent_targets_and_no_future_feature(store):
|
||||
for item in series_module.matched_variation(built["reconstructed"], horizon=7):
|
||||
if item["day"] == row["day"]:
|
||||
expected = item["delta_cents"]
|
||||
assert row["features"]["local_matched_7"] == expected, "feature connue au jour J"
|
||||
assert row["features"]["local_matched_7"] is None, "ancienne feature contaminée désactivée"
|
||||
assert row["targets"][7] == expected, "cible au jour J+7"
|
||||
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ def test_forecast_is_ignored_until_it_beats_the_naive_rule(store):
|
||||
)
|
||||
out = forecast.outlook("Gazole")
|
||||
assert out["status"] == "insufficient"
|
||||
assert "règle naïve" in out["reason"]
|
||||
assert "fuite de cible" in out["reason"]
|
||||
storage.save_forecast(
|
||||
dict(
|
||||
fuel="Gazole",
|
||||
@@ -359,7 +359,7 @@ def test_forecast_is_ignored_until_it_beats_the_naive_rule(store):
|
||||
)
|
||||
)
|
||||
out = forecast.outlook("Gazole")
|
||||
assert out["status"] == "ok" and out["direction"] == "down" and out["model"] == "test-v2"
|
||||
assert out["status"] == "insufficient" # même un ancien score élevé est invalidé
|
||||
|
||||
|
||||
def test_absent_model_is_declared_absent(store):
|
||||
@@ -367,7 +367,7 @@ def test_absent_model_is_declared_absent(store):
|
||||
|
||||
out = forecast.outlook("Gazole")
|
||||
assert out["status"] == "insufficient"
|
||||
assert "pas encore entraîné" in out["reason"]
|
||||
assert "Modèle expérimental — non validé" in out["reason"]
|
||||
|
||||
|
||||
def test_local_rank_never_triggers_a_full_tank(store):
|
||||
|
||||
Reference in New Issue
Block a user