Skip to content

Commit 0e7ec49

Browse files
fix: align tests with pragmatic refactoring api changes
1 parent 2f0c153 commit 0e7ec49

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

tests/test_data.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
"""Tests para el módulo de datos de pases."""
1+
"""Tests para el módulo de datos de pases alineados con la refactorización pragmática."""
22
import pytest
33
import pandas as pd
4-
from unittest.mock import patch
5-
from united_passing.data import clean_passes, build_midfield_report
6-
from united_passing.analysis import top_by_prog_ratio, filter_midfielders, resumen_estadisticas
4+
from united_passing.data import sanitize, gen_mf_report
5+
from united_passing.analysis import top_prog, mfs_only, slim_stats
76

87

98
# ── Fixtures ──────────────────────────────────────────────────────────────────
@@ -23,10 +22,10 @@ def raw_df() -> pd.DataFrame:
2322

2423
@pytest.fixture
2524
def clean_df(raw_df) -> pd.DataFrame:
26-
return clean_passes(raw_df)
25+
return sanitize(raw_df)
2726

2827

29-
# ── Tests: clean_passes ───────────────────────────────────────────────────────
28+
# ── Tests: sanitize ───────────────────────────────────────────────────────
3029

3130
def test_clean_removes_empty_columns(clean_df):
3231
assert "EmptyCol" not in clean_df.columns
@@ -42,57 +41,57 @@ def test_clean_empty_string_to_nan(clean_df):
4241
assert pd.isna(clean_df.loc[3, "Cmp"])
4342

4443

45-
# ── Tests: build_midfield_report ──────────────────────────────────────────────
44+
# ── Tests: gen_mf_report ──────────────────────────────────────────────
4645

4746
def test_build_midfield_report_filters_mf(clean_df):
48-
report = build_midfield_report(clean_df)
47+
report = gen_mf_report(clean_df)
4948
assert all(report["Pos"].str.contains("MF"))
5049

5150

5251
def test_build_midfield_report_adds_prog_ratio(clean_df):
53-
report = build_midfield_report(clean_df)
52+
report = gen_mf_report(clean_df)
5453
assert "Prog_Ratio" in report.columns
5554

5655

5756
def test_build_midfield_report_sorted_desc(clean_df):
58-
report = build_midfield_report(clean_df)
57+
report = gen_mf_report(clean_df)
5958
ratios = report["Prog_Ratio"].tolist()
6059
assert ratios == sorted(ratios, reverse=True)
6160

6261

6362
# ── Tests: analysis ───────────────────────────────────────────────────────────
6463

6564
def test_top_by_prog_ratio_calculates_if_missing(clean_df):
66-
result = top_by_prog_ratio(clean_df, top_n=2)
65+
result = top_prog(clean_df, tops=2)
6766
assert len(result) <= 2
6867
assert "Prog_Ratio" in result.columns
6968

7069

7170
def test_top_by_prog_ratio_respects_top_n(clean_df):
72-
result = top_by_prog_ratio(clean_df, top_n=1)
71+
result = top_prog(clean_df, tops=1)
7372
assert len(result) == 1
7473

7574

7675
def test_filter_midfielders(clean_df):
77-
mf = filter_midfielders(clean_df)
76+
mf = mfs_only(clean_df)
7877
assert all(mf["Pos"].str.contains("MF"))
7978

8079

8180
def test_filter_midfielders_no_pos_column():
8281
df = pd.DataFrame({"Player": ["A", "B"], "Cmp": [10, 20]})
83-
result = filter_midfielders(df)
82+
result = mfs_only(df)
8483
assert len(result) == 2
8584

8685

8786
def test_resumen_estadisticas_cols(clean_df):
88-
res = resumen_estadisticas(clean_df)
87+
res = slim_stats(clean_df)
8988
assert "Player" in res.columns
9089
assert "Cmp" in res.columns
9190

9291

9392
# ── Tests: load_data (smoke) ──────────────────────────────────────────────────
9493

9594
def test_load_data_file_not_found():
96-
from united_passing.data import load_data
95+
from united_passing.data import pull_files
9796
with pytest.raises(FileNotFoundError):
98-
load_data(passes_path="no_existe.csv")
97+
pull_files(base="no_existe.csv", rep="tampoco.csv")

0 commit comments

Comments
 (0)