mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 15:26:15 +00:00
fix(data): normalize station history dates
This commit is contained in:
1 parent
2a34054399
commit
04eb0fde61
3 files changed
+115
-5
No files matched your search
@@ -0,0 +1,48 @@
|
||||
"""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"]
|
||||
Reference in new issue
Block a user