Spaces:
Running
Running
| from __future__ import annotations | |
| from pathlib import Path | |
| import pandas as pd | |
| import pytest | |
| from racing_reports.config import Settings | |
| from racing_reports.datastore import DataStore | |
| from racing_reports.utils import slugify | |
| def sample_store(tmp_path: Path) -> DataStore: | |
| settings = Settings(cache_dir=tmp_path / "cache", output_dir=tmp_path / "outputs") | |
| store = DataStore(settings=settings) | |
| league = "Spanish Segunda Division" | |
| season = "25-26" | |
| path = store.preprocessed_path(league, season) | |
| path.parent.mkdir(parents=True, exist_ok=True) | |
| rows = [] | |
| for match_id, home, away, home_id, away_id, date in [ | |
| ("m1", "Racing de Santander", "Almería", "racing", "almeria", "2026-04-12"), | |
| ("m2", "Huesca", "Racing de Santander", "huesca", "racing", "2026-04-19"), | |
| ]: | |
| for sequence_id, phase in [ | |
| ("s1", "Build Up against Low Block"), | |
| ("s2", "Build Up against Medium Block"), | |
| ("s3", "Build Up against High Block"), | |
| ]: | |
| for team, rival, team_id in [(home, away, home_id), (away, home, away_id)]: | |
| rows.append( | |
| { | |
| "matchId": match_id, | |
| "fecha": date, | |
| "home_team_id": home_id, | |
| "away_team_id": away_id, | |
| "teamId": team_id, | |
| "TeamName": team, | |
| "TeamRival": rival, | |
| "Competencia": league, | |
| "Temporada": season, | |
| "sequenceId": sequence_id, | |
| "phaseLabel": phase, | |
| "event_name": "Goal" if sequence_id == "s1" and team == home else "Pass", | |
| "x": 88, | |
| "y": 50, | |
| "xG": 0.08 if sequence_id == "s1" else 0, | |
| "pvAdded": 0.03, | |
| "goal_int": 1 if sequence_id == "s1" and team == home else 0, | |
| } | |
| ) | |
| pd.DataFrame(rows).to_csv(path, index=False) | |
| return store | |