Spaces:
Running
Running
File size: 2,136 Bytes
9da4e9c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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
@pytest.fixture()
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
|