11"""Pytest configuration and fixtures."""
22
33import json
4+ from collections .abc import Generator
45from pathlib import Path
6+ from typing import Any
57
68import pytest
79import respx
1113FIXTURES_DIR = Path (__file__ ).parent / "fixtures"
1214
1315
14- def load_fixture (name : str ) -> dict | list :
16+ def load_fixture (name : str ) -> dict [ str , Any ] | list [ Any ] :
1517 """Load a JSON fixture file."""
1618 with open (FIXTURES_DIR / name ) as f :
17- return json .load (f )
19+ data : dict [str , Any ] | list [Any ] = json .load (f )
20+ return data
1821
1922
2023@pytest .fixture
@@ -24,79 +27,103 @@ def client() -> MCSRRanked:
2427
2528
2629@pytest .fixture
27- def mock_api () -> respx .MockRouter :
30+ def mock_api () -> Generator [ respx .MockRouter , None , None ] :
2831 """Create a mock API router."""
2932 with respx .mock (base_url = "https://api.mcsrranked.com" ) as respx_mock :
3033 yield respx_mock
3134
3235
3336@pytest .fixture
34- def user_fixture () -> dict :
37+ def user_fixture () -> dict [ str , Any ] :
3538 """Load user.json fixture (Feinberg's profile)."""
36- return load_fixture ("user.json" )
39+ result = load_fixture ("user.json" )
40+ assert isinstance (result , dict )
41+ return result
3742
3843
3944@pytest .fixture
40- def user_matches_fixture () -> list :
45+ def user_matches_fixture () -> list [ Any ] :
4146 """Load user_matches.json fixture (Feinberg's recent matches)."""
42- return load_fixture ("user_matches.json" )
47+ result = load_fixture ("user_matches.json" )
48+ assert isinstance (result , list )
49+ return result
4350
4451
4552@pytest .fixture
46- def user_seasons_fixture () -> dict :
53+ def user_seasons_fixture () -> dict [ str , Any ] :
4754 """Load user_seasons.json fixture (Feinberg's season history)."""
48- return load_fixture ("user_seasons.json" )
55+ result = load_fixture ("user_seasons.json" )
56+ assert isinstance (result , dict )
57+ return result
4958
5059
5160@pytest .fixture
52- def versus_fixture () -> dict :
61+ def versus_fixture () -> dict [ str , Any ] :
5362 """Load versus.json fixture (Feinberg vs Couriway stats)."""
54- return load_fixture ("versus.json" )
63+ result = load_fixture ("versus.json" )
64+ assert isinstance (result , dict )
65+ return result
5566
5667
5768@pytest .fixture
58- def versus_matches_fixture () -> list :
69+ def versus_matches_fixture () -> list [ Any ] :
5970 """Load versus_matches.json fixture (Feinberg vs Couriway matches)."""
60- return load_fixture ("versus_matches.json" )
71+ result = load_fixture ("versus_matches.json" )
72+ assert isinstance (result , list )
73+ return result
6174
6275
6376@pytest .fixture
64- def matches_fixture () -> list :
77+ def matches_fixture () -> list [ Any ] :
6578 """Load matches.json fixture (recent ranked matches)."""
66- return load_fixture ("matches.json" )
79+ result = load_fixture ("matches.json" )
80+ assert isinstance (result , list )
81+ return result
6782
6883
6984@pytest .fixture
70- def match_detail_fixture () -> dict :
85+ def match_detail_fixture () -> dict [ str , Any ] :
7186 """Load match_detail.json fixture (single match details)."""
72- return load_fixture ("match_detail.json" )
87+ result = load_fixture ("match_detail.json" )
88+ assert isinstance (result , dict )
89+ return result
7390
7491
7592@pytest .fixture
76- def leaderboard_fixture () -> dict :
93+ def leaderboard_fixture () -> dict [ str , Any ] :
7794 """Load leaderboard.json fixture (elo leaderboard)."""
78- return load_fixture ("leaderboard.json" )
95+ result = load_fixture ("leaderboard.json" )
96+ assert isinstance (result , dict )
97+ return result
7998
8099
81100@pytest .fixture
82- def phase_leaderboard_fixture () -> dict :
101+ def phase_leaderboard_fixture () -> dict [ str , Any ] :
83102 """Load phase_leaderboard.json fixture."""
84- return load_fixture ("phase_leaderboard.json" )
103+ result = load_fixture ("phase_leaderboard.json" )
104+ assert isinstance (result , dict )
105+ return result
85106
86107
87108@pytest .fixture
88- def record_leaderboard_fixture () -> dict :
109+ def record_leaderboard_fixture () -> list [ Any ] :
89110 """Load record_leaderboard.json fixture."""
90- return load_fixture ("record_leaderboard.json" )
111+ result = load_fixture ("record_leaderboard.json" )
112+ assert isinstance (result , list )
113+ return result
91114
92115
93116@pytest .fixture
94- def live_fixture () -> dict :
117+ def live_fixture () -> dict [ str , Any ] :
95118 """Load live.json fixture (live matches)."""
96- return load_fixture ("live.json" )
119+ result = load_fixture ("live.json" )
120+ assert isinstance (result , dict )
121+ return result
97122
98123
99124@pytest .fixture
100- def weekly_race_fixture () -> dict :
125+ def weekly_race_fixture () -> dict [ str , Any ] :
101126 """Load weekly_race.json fixture."""
102- return load_fixture ("weekly_race.json" )
127+ result = load_fixture ("weekly_race.json" )
128+ assert isinstance (result , dict )
129+ return result
0 commit comments