Files
skipredictor/tests/test_infonieve_historical.py

49 lines
1.2 KiB
Python

"""Regression tests for Infonieve historical date normalization."""
from __future__ import annotations
from datetime import date
import pandas as pd
from data_sources.infonieve_historical import _normalise_history_dates
def test_normalise_history_dates_keeps_iso_dates_in_place():
"""ISO dates must not be reinterpreted as day-first variants."""
df = pd.DataFrame(
{
"date": ["2026-04-10", "2026-04-11", "2026-04-12", "2026-05-09"],
"station_id": ["pajares"] * 4,
}
)
normalised = _normalise_history_dates(
df,
cutoff_date=date(2026, 5, 9),
)
assert normalised["date"].dt.strftime("%Y-%m-%d").tolist() == [
"2026-04-10",
"2026-04-11",
"2026-04-12",
"2026-05-09",
]
def test_normalise_history_dates_drops_future_rows():
"""Rows after the cutoff must be excluded from the historical dataset."""
df = pd.DataFrame(
{
"date": ["2026-03-12", "2026-03-13", "2026-03-14", "2026-05-09"],
"station_id": ["sanisidro"] * 4,
}
)
normalised = _normalise_history_dates(
df,
cutoff_date=date(2026, 3, 12),
)
assert normalised["date"].dt.strftime("%Y-%m-%d").tolist() == ["2026-03-12"]