PyTest

conftest

Pytest top-level conftest.py.

show_log_output

show_log_output()

Turn on/off example code stdout logging output.

Returns:
  • bool( bool ) –

    Boolean value representing if log output is turned on or off.

Source code in test/conftest.py
11
12
13
14
15
16
17
18
19
20
@pytest.fixture
def show_log_output() -> bool:
    """Turn on/off example code stdout logging output.

    Returns:
        bool: Boolean value representing if log output is turned on or off.

    """
    log_output = False
    return log_output

integration

Pytest integration tests for YFPY.

conftest

Pytest integration test conftest.py.

data_dir

data_dir()

Code tests will output data to this directory.

Source code in test/integration/conftest.py
25
26
27
28
@pytest.fixture
def data_dir() -> Path:
    """Code tests will output data to this directory."""
    return Path(__file__).parent / "test_output"

yahoo_data

yahoo_data(data_dir)

Instantiate yfpy Data object.

Source code in test/integration/conftest.py
31
32
33
34
@pytest.fixture
def yahoo_data(data_dir: Union[Path, str]) -> Data:
    """Instantiate yfpy Data object."""
    return Data(data_dir)

yahoo_query

yahoo_query(
    league_id, game_code, game_id, browser_callback
)

Instantiate yfpy YahooFantasySportsQuery object and override league key.

Source code in test/integration/conftest.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@pytest.fixture
def yahoo_query(league_id: str, game_code: str, game_id: int, browser_callback: bool) -> YahooFantasySportsQuery:
    """Instantiate yfpy YahooFantasySportsQuery object and override league key."""
    yahoo_query = YahooFantasySportsQuery(
        league_id,
        game_code,
        game_id=game_id,
        yahoo_consumer_key=os.environ.get("YFPY_CONSUMER_KEY"),
        yahoo_consumer_secret=os.environ.get("YFPY_CONSUMER_SECRET"),
        env_file_location=Path(__file__).parent.parent.parent / "env",
        all_output_as_json_str=False,
        browser_callback=browser_callback,
        offline=False,
    )

    # Manually override league key for example code to work
    yahoo_query.league_key = f"{game_id}.l.{league_id}"

    return yahoo_query

browser_callback

browser_callback()

Turn on/off automatic opening of browser window for OAuth.

Source code in test/integration/conftest.py
58
59
60
61
62
@pytest.fixture
def browser_callback() -> bool:
    """Turn on/off automatic opening of browser window for OAuth."""
    browser_callback = True
    return browser_callback

season

season()

Set Yahoo Fantasy Sports season for testing.

Source code in test/integration/conftest.py
65
66
67
68
@pytest.fixture
def season() -> int:
    """Set Yahoo Fantasy Sports season for testing."""
    return quickstart.get_season()

chosen_week

chosen_week()

Set Yahoo Fantasy Sports chosen week for testing.

Source code in test/integration/conftest.py
71
72
73
74
@pytest.fixture
def chosen_week() -> int:
    """Set Yahoo Fantasy Sports chosen week for testing."""
    return quickstart.get_chosen_week()

chosen_date

chosen_date()

Set Yahoo Fantasy Sports chosen date for testing.

Source code in test/integration/conftest.py
77
78
79
80
@pytest.fixture
def chosen_date() -> str:
    """Set Yahoo Fantasy Sports chosen date for testing."""
    return quickstart.get_chosen_date()

game_code

game_code()

Set Yahoo Fantasy Sports game code for testing.

Source code in test/integration/conftest.py
83
84
85
86
@pytest.fixture
def game_code() -> str:
    """Set Yahoo Fantasy Sports game code for testing."""
    return quickstart.get_game_code()

game_id

game_id()

Set Yahoo Fantasy Sports game ID for testing.

Source code in test/integration/conftest.py
89
90
91
92
@pytest.fixture
def game_id() -> int:
    """Set Yahoo Fantasy Sports game ID for testing."""
    return quickstart.get_game_id()

game_key

game_key()

Set Yahoo Fantasy Sports game key for testing.

Source code in test/integration/conftest.py
95
96
97
98
@pytest.fixture
def game_key() -> str:
    """Set Yahoo Fantasy Sports game key for testing."""
    return quickstart.get_game_key()

league_id

league_id()

Set Yahoo Fantasy Sports league ID for testing.

Source code in test/integration/conftest.py
101
102
103
104
@pytest.fixture
def league_id() -> str:
    """Set Yahoo Fantasy Sports league ID for testing."""
    return quickstart.get_league_id()

team_id

team_id()

Set Yahoo Fantasy Sports team ID for testing.

Source code in test/integration/conftest.py
107
108
109
110
@pytest.fixture
def team_id() -> int:
    """Set Yahoo Fantasy Sports team ID for testing."""
    return quickstart.get_team_id()

team_name

team_name()

Set Yahoo Fantasy Sports team name for testing.

Source code in test/integration/conftest.py
113
114
115
116
@pytest.fixture
def team_name() -> str:
    """Set Yahoo Fantasy Sports team name for testing."""
    return quickstart.get_team_name()

player_id

player_id()

Create and set Yahoo Fantasy Sports player ID for testing.

Source code in test/integration/conftest.py
119
120
121
122
@pytest.fixture
def player_id() -> int:
    """Create and set Yahoo Fantasy Sports player ID for testing."""
    return quickstart.get_player_id()

player_key

player_key(game_id, player_id)

Create and set Yahoo Fantasy Sports player key for testing.

Source code in test/integration/conftest.py
125
126
127
128
129
130
131
@pytest.fixture
def player_key(game_id, player_id) -> str:
    """Create and set Yahoo Fantasy Sports player key for testing."""

    player_key = f"{game_id}.p.{player_id}"

    return player_key

league_player_limit

league_player_limit()

Set Yahoo Fantasy Sports league player retrieval limit for testing.

Source code in test/integration/conftest.py
134
135
136
137
@pytest.fixture
def league_player_limit() -> int:
    """Set Yahoo Fantasy Sports league player retrieval limit for testing."""
    return quickstart.get_league_player_limit()

test_api_game_data

Pytest integration tests for Yahoo Fantasy Sports API game data.

Note

Tests saving and loading all Yahoo Fantasy Sports API game data.

Attributes:
  • logger (Logger) –

    Game data integration tests logger.

test_get_all_yahoo_fantasy_game_keys

test_get_all_yahoo_fantasy_game_keys(
    yahoo_query,
    yahoo_data,
    game_code,
    game_id,
    show_log_output,
)

Integration test for retrieval of all Yahoo fantasy football game keys.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_all_yahoo_fantasy_game_keys.

Source code in test/integration/test_api_game_data.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@pytest.mark.integration
def test_get_all_yahoo_fantasy_game_keys(yahoo_query, yahoo_data, game_code, game_id, show_log_output):
    """Integration test for retrieval of all Yahoo fantasy football game keys.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_all_yahoo_fantasy_game_keys`.

    """
    query_result_data = yahoo_data.save(
        f"{game_code}-game_keys",
        yahoo_query.get_all_yahoo_fantasy_game_keys
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{game_code}-game_keys",
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(f"{prettify_data(loaded_result_data)}\n----------\n")

    assert query_result_data == loaded_result_data

test_get_game_key_by_season

test_get_game_key_by_season(
    yahoo_query, season, game_key, show_log_output
)

Integration test for retrieval of specific game key by season.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_game_key_by_season.

Source code in test/integration/test_api_game_data.py
57
58
59
60
61
62
63
64
65
66
67
68
69
@pytest.mark.integration
def test_get_game_key_by_season(yahoo_query, season, game_key, show_log_output):
    """Integration test for retrieval of specific game key by season.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_game_key_by_season`.

    """
    query_result_data = yahoo_query.get_game_key_by_season(season=season)
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    assert query_result_data == game_key

test_get_current_game_info

test_get_current_game_info(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of game info for current fantasy season.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_current_game_info.

Source code in test/integration/test_api_game_data.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
@pytest.mark.integration
def test_get_current_game_info(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of game info for current fantasy season.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_current_game_info`.

    """
    query_result_data = yahoo_data.save(
        "current-game-info",
        yahoo_query.get_current_game_info
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        "current-game-info",
        Game,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_current_game_metadata

test_get_current_game_metadata(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of game metadata for current fantasy season.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_current_game_metadata.

Source code in test/integration/test_api_game_data.py
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
@pytest.mark.integration
def test_get_current_game_metadata(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of game metadata for current fantasy season.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_current_game_metadata`.

    """
    query_result_data = yahoo_data.save(
        "current-game-metadata",
        yahoo_query.get_current_game_metadata
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        "current-game-metadata",
        Game,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_game_info_by_game_id

test_get_game_info_by_game_id(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of game info for specific game by id.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_game_info_by_game_id.

Source code in test/integration/test_api_game_data.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
@pytest.mark.integration
def test_get_game_info_by_game_id(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of game info for specific game by id.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_game_info_by_game_id`.

    """
    new_data_dir = data_dir / str(season)
    query_result_data = yahoo_data.save(
        f"{game_id}-game-info",
        yahoo_query.get_game_info_by_game_id,
        params={"game_id": game_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{game_id}-game-info",
        Game,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_game_metadata_by_game_id

test_get_game_metadata_by_game_id(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of game metadata for specific game by id.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_game_metadata_by_game_id.

Source code in test/integration/test_api_game_data.py
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
@pytest.mark.integration
def test_get_game_metadata_by_game_id(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of game metadata for specific game by id.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_game_metadata_by_game_id`.

    """
    new_data_dir = data_dir / str(season)
    query_result_data = yahoo_data.save(
        f"{game_id}-game-metadata",
        yahoo_query.get_game_metadata_by_game_id,
        params={"game_id": game_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{game_id}-game-metadata",
        Game,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_league_key

test_get_league_key(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    show_log_output,
)

Integration test for retrieval of league key for selected league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_key.

Source code in test/integration/test_api_game_data.py
184
185
186
187
188
189
190
191
192
193
194
195
196
@pytest.mark.integration
def test_get_league_key(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, show_log_output):
    """Integration test for retrieval of league key for selected league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_key`.

    """
    query_result_data = yahoo_query.get_league_key()
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    assert query_result_data == f"{game_id}.l.{league_id}"

test_get_game_weeks_by_game_id

test_get_game_weeks_by_game_id(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of all valid weeks of a specific game by id.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_game_weeks_by_game_id.

Source code in test/integration/test_api_game_data.py
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
@pytest.mark.integration
def test_get_game_weeks_by_game_id(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of all valid weeks of a specific game by id.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_game_weeks_by_game_id`.

    """
    new_data_dir = data_dir / str(season)
    query_result_data = yahoo_data.save(
        f"{game_id}-game-weeks",
        yahoo_query.get_game_weeks_by_game_id,
        params={"game_id": game_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{game_id}-game-weeks",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_game_stat_categories_by_game_id

test_get_game_stat_categories_by_game_id(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of all valid stat categories of a specific game by id.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_game_stat_categories_by_game_id.

Source code in test/integration/test_api_game_data.py
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
@pytest.mark.integration
def test_get_game_stat_categories_by_game_id(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of all valid stat categories of a specific game by id.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_game_stat_categories_by_game_id`.

    """
    new_data_dir = data_dir / str(season)
    query_result_data = yahoo_data.save(
        f"{game_id}-game-stat_categories",
        yahoo_query.get_game_stat_categories_by_game_id,
        params={"game_id": game_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{game_id}-game-stat_categories",
        StatCategories,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    assert query_result_data == loaded_result_data

test_get_game_position_types_by_game_id

test_get_game_position_types_by_game_id(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of all valid position types for specific game by id.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_game_position_types_by_game_id.

Source code in test/integration/test_api_game_data.py
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
@pytest.mark.integration
def test_get_game_position_types_by_game_id(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of all valid position types for specific game by id.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_game_position_types_by_game_id`.

    """
    new_data_dir = data_dir / str(season)
    query_result_data = yahoo_data.save(
        f"{game_id}-game-position_types",
        yahoo_query.get_game_position_types_by_game_id,
        params={"game_id": game_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{game_id}-game-position_types",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_game_roster_positions_by_game_id

test_get_game_roster_positions_by_game_id(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of all valid roster positions for specific game by id.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_game_roster_positions_by_game_id.

Source code in test/integration/test_api_game_data.py
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
@pytest.mark.integration
def test_get_game_roster_positions_by_game_id(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of all valid roster positions for specific game by id.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_game_roster_positions_by_game_id`.

    """
    new_data_dir = data_dir / str(season)
    query_result_data = yahoo_data.save(
        f"{game_id}-game-roster_positions",
        yahoo_query.get_game_roster_positions_by_game_id,
        params={"game_id": game_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{game_id}-game-roster_positions",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_api_league_data

Pytest integration tests for Yahoo Fantasy Sports API league data.

Note

Tests saving and loading all Yahoo Fantasy Sports API league data.

Attributes:
  • logger (Logger) –

    Game data integration tests logger.

test_get_league_info

test_get_league_info(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    show_log_output,
)

Integration test for retrieval of info for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_info.

Source code in test/integration/test_api_league_data.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@pytest.mark.integration
def test_get_league_info(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, show_log_output):
    """Integration test for retrieval of info for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_info`.

    """

    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}"
    query_result_data = yahoo_data.save(
        f"{league_id}-league-info",
        yahoo_query.get_league_info,
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{league_id}-league-info",
        League,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_league_metadata

test_get_league_metadata(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    show_log_output,
)

Integration test for retrieval of metadata for chosen Yahoo fantasy league..

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_metadata.

Source code in test/integration/test_api_league_data.py
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
@pytest.mark.integration
def test_get_league_metadata(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, show_log_output):
    """Integration test for retrieval of metadata for chosen Yahoo fantasy league..

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_metadata`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}"
    query_result_data = yahoo_data.save(
        f"{league_id}-league-metadata",
        yahoo_query.get_league_metadata,
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{league_id}-league-metadata",
        League,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_league_settings

test_get_league_settings(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    show_log_output,
)

Integration test for retrieval of settings for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_settings.

Source code in test/integration/test_api_league_data.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
@pytest.mark.integration
def test_get_league_settings(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, show_log_output):
    """Integration test for retrieval of settings for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_settings`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}"
    query_result_data = yahoo_data.save(
        f"{league_id}-league-settings",
        yahoo_query.get_league_settings,
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{league_id}-league-settings",
        Settings,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_league_standings

test_get_league_standings(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    show_log_output,
)

Integration test for retrieval of standings for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_standings.

Source code in test/integration/test_api_league_data.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
@pytest.mark.integration
def test_get_league_standings(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, show_log_output):
    """Integration test for retrieval of standings for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_standings`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}"
    query_result_data = yahoo_data.save(
        f"{league_id}-league-standings",
        yahoo_query.get_league_standings,
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{league_id}-league-standings",
        Standings,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_league_teams

test_get_league_teams(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    show_log_output,
)

Integration test for retrieval of all teams in chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_teams.

Source code in test/integration/test_api_league_data.py
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
@pytest.mark.integration
def test_get_league_teams(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, show_log_output):
    """Integration test for retrieval of all teams in chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_teams`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}"
    query_result_data = yahoo_data.save(
        f"{league_id}-league-teams",
        yahoo_query.get_league_teams,
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{league_id}-league-teams",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_league_players

test_get_league_players(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    show_log_output,
)

Integration test for retrieval of players in chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_players.

Source code in test/integration/test_api_league_data.py
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
@pytest.mark.skip(
    reason="Skipping test_get_league_players: high player volume slows down tests. Run this test separately."
)
@pytest.mark.integration
def test_get_league_players(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, show_log_output):
    """Integration test for retrieval of players in chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_players`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}"
    query_result_data = yahoo_data.save(
        f"{league_id}-league-players",
        yahoo_query.get_league_players,
        # params={"player_count_start": 1400, "player_count_limit": 1475},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{league_id}-league-players",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_league_players_with_limit

test_get_league_players_with_limit(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    league_player_limit,
    show_log_output,
)

Integration test for retrieval of a specified maximum of players in chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_players.

Source code in test/integration/test_api_league_data.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
@pytest.mark.integration
def test_get_league_players_with_limit(yahoo_query, yahoo_data, data_dir, season, game_id, league_id,
                                       league_player_limit, show_log_output):
    """Integration test for retrieval of a specified maximum of players in chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_players`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}"
    query_result_data = yahoo_data.save(
        f"{league_id}-league-players",
        yahoo_query.get_league_players,
        params={"player_count_limit": league_player_limit},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{league_id}-league-players",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_league_draft_results

test_get_league_draft_results(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    show_log_output,
)

Integration test for retrieval of draft results for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_draft_results.

Source code in test/integration/test_api_league_data.py
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
@pytest.mark.integration
def test_get_league_draft_results(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, show_log_output):
    """Integration test for retrieval of draft results for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_draft_results`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}"
    query_result_data = yahoo_data.save(
        f"{league_id}-league-draft_results",
        yahoo_query.get_league_draft_results,
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{league_id}-league-draft_results",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_league_transactions

test_get_league_transactions(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    show_log_output,
)

Integration test for retrieval of transactions for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_transactions.

Source code in test/integration/test_api_league_data.py
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
@pytest.mark.integration
def test_get_league_transactions(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, show_log_output):
    """Integration test for retrieval of transactions for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_transactions`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}"
    query_result_data = yahoo_data.save(
        f"{league_id}-league-transactions",
        yahoo_query.get_league_transactions,
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{league_id}-league-transactions",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_league_scoreboard_by_week

test_get_league_scoreboard_by_week(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    chosen_week,
    game_id,
    league_id,
    show_log_output,
)

Integration test for retrieval of scoreboard by week for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_scoreboard_by_week.

Source code in test/integration/test_api_league_data.py
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
@pytest.mark.integration
def test_get_league_scoreboard_by_week(yahoo_query, yahoo_data, data_dir, season, chosen_week, game_id, league_id,
                                       show_log_output):
    """Integration test for retrieval of scoreboard by week for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_scoreboard_by_week`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / f"week_{chosen_week}"
    query_result_data = yahoo_data.save(
        f"week_{chosen_week}-scoreboard",
        yahoo_query.get_league_scoreboard_by_week,
        params={"chosen_week": chosen_week},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"week_{chosen_week}-scoreboard",
        Scoreboard,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_league_matchups_by_week

test_get_league_matchups_by_week(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    chosen_week,
    game_id,
    league_id,
    show_log_output,
)

Integration test for retrieval of matchups by week for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_league_matchups_by_week.

Source code in test/integration/test_api_league_data.py
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
@pytest.mark.integration
def test_get_league_matchups_by_week(yahoo_query, yahoo_data, data_dir, season, chosen_week, game_id, league_id,
                                     show_log_output):
    """Integration test for retrieval of matchups by week for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_league_matchups_by_week`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / f"week_{chosen_week}"
    query_result_data = yahoo_data.save(
        f"week_{chosen_week}-matchups",
        yahoo_query.get_league_matchups_by_week,
        params={"chosen_week": chosen_week},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"week_{chosen_week}-matchups",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_api_player_data

Pytest integration tests for Yahoo Fantasy Sports API player data.

Note

Tests saving and loading all Yahoo Fantasy Sports API player data.

Attributes:
  • logger (Logger) –

    Game data integration tests logger.

test_get_player_stats_for_season

test_get_player_stats_for_season(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    player_id,
    player_key,
    show_log_output,
)

Integration test for retrieval of player stats by season for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_player_stats_for_season.

Source code in test/integration/test_api_player_data.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@pytest.mark.integration
def test_get_player_stats_for_season(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, player_id,
                                     player_key, show_log_output):
    """Integration test for retrieval of player stats by season for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_player_stats_for_season`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / "players"
    query_result_data = yahoo_data.save(
        f"{player_id}-player-season-stats",
        yahoo_query.get_player_stats_for_season,
        params={"player_key": str(player_key)},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{player_id}-player-season-stats",
        Player,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_player_stats_by_week

test_get_player_stats_by_week(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    chosen_week,
    game_id,
    league_id,
    player_id,
    player_key,
    show_log_output,
)

Integration test for retrieval of player stats by week for chosen Yahoo fantasy league..

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_player_stats_by_week.

Source code in test/integration/test_api_player_data.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@pytest.mark.integration
def test_get_player_stats_by_week(yahoo_query, yahoo_data, data_dir, season, chosen_week, game_id, league_id,
                                  player_id, player_key, show_log_output):
    """Integration test for retrieval of player stats by week for chosen Yahoo fantasy league..

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_player_stats_by_week`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / f"week_{chosen_week}" / "players"
    query_result_data = yahoo_data.save(
        f"{player_id}-player-stats",
        yahoo_query.get_player_stats_by_week,
        params={"player_key": str(player_key), "chosen_week": str(chosen_week)},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{player_id}-player-stats",
        Player,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_player_stats_by_date

test_get_player_stats_by_date(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    chosen_date,
    game_id,
    league_id,
    player_id,
    player_key,
    show_log_output,
)

Integration test for retrieval of player stats by date for Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_player_stats_by_date.

Source code in test/integration/test_api_player_data.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
@pytest.mark.skip(
    reason="Skipping test_get_player_stats_by_date: retrieval by date supported by NHL/NBA/MLB, not NFL."
)
@pytest.mark.integration
def test_get_player_stats_by_date(yahoo_query, yahoo_data, data_dir, season, chosen_date, game_id, league_id,
                                  player_id, player_key, show_log_output):
    """Integration test for retrieval of player stats by date for Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_player_stats_by_date`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / str(chosen_date) / "players"
    query_result_data = yahoo_data.save(
        f"{player_id}-player-stats",
        yahoo_query.get_player_stats_by_date,
        params={"player_key": str(player_key), "chosen_date": chosen_date},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{player_id}-player-stats",
        Player,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_player_ownership

test_get_player_ownership(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    player_id,
    player_key,
    show_log_output,
)

Integration test for retrieval of ownership of chosen player for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_player_ownership.

Source code in test/integration/test_api_player_data.py
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
@pytest.mark.integration
def test_get_player_ownership(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, player_id, player_key,
                              show_log_output):
    """Integration test for retrieval of ownership of chosen player for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_player_ownership`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / "players"
    query_result_data = yahoo_data.save(
        f"{player_id}-player-ownership",
        yahoo_query.get_player_ownership,
        params={"player_key": str(player_key)},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{player_id}-player-ownership",
        Player,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_player_percent_owned_by_week

test_get_player_percent_owned_by_week(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    chosen_week,
    game_id,
    league_id,
    player_id,
    player_key,
    show_log_output,
)

Integration test for retrieval of percent ownership by week of chosen player for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_player_percent_owned_by_week.

Source code in test/integration/test_api_player_data.py
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
@pytest.mark.integration
def test_get_player_percent_owned_by_week(yahoo_query, yahoo_data, data_dir, season, chosen_week, game_id, league_id,
                                          player_id, player_key, show_log_output):
    """Integration test for retrieval of percent ownership by week of chosen player for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_player_percent_owned_by_week`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / f"week_{chosen_week}" / "players"
    query_result_data = yahoo_data.save(
        f"{player_id}-player-percent_owned",
        yahoo_query.get_player_percent_owned_by_week,
        params={"player_key": str(player_key), "chosen_week": str(chosen_week)},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{player_id}-player-percent_owned",
        Player,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_player_draft_analysis

test_get_player_draft_analysis(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    player_id,
    player_key,
    show_log_output,
)

Integration test for retrieval of player draft analysis of chosen player for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_player_draft_analysis.

Source code in test/integration/test_api_player_data.py
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
@pytest.mark.integration
def test_get_player_draft_analysis(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, player_id,
                                   player_key, show_log_output):
    """Integration test for retrieval of player draft analysis of chosen player for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_player_draft_analysis`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / "players"
    query_result_data = yahoo_data.save(
        f"{player_id}-player-draft_analysis",
        yahoo_query.get_player_draft_analysis,
        params={"player_key": str(player_key)}, new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{player_id}-player-draft_analysis",
        Player,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_api_team_data

Pytest integration tests for Yahoo Fantasy Sports API team data.

Note

Tests saving and loading all Yahoo Fantasy Sports API team data.

Attributes:
  • logger (Logger) –

    Game data integration tests logger.

test_get_team_info

test_get_team_info(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of info for chosen team by team ID for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_info.

Source code in test/integration/test_api_team_data.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@pytest.mark.integration
def test_get_team_info(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, team_id, team_name,
                       show_log_output):
    """Integration test for retrieval of info for chosen team by team ID for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_info`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / "teams" / f"{team_id}-{team_name}"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-info",
        yahoo_query.get_team_info,
        params={"team_id": team_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-info",
        Team,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_team_metadata

test_get_team_metadata(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of metadata for chosen team by team ID for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_metadata.

Source code in test/integration/test_api_team_data.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@pytest.mark.integration
def test_get_team_metadata(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, team_id, team_name,
                           show_log_output):
    """Integration test for retrieval of metadata for chosen team by team ID for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_metadata`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / "teams" / f"{team_id}-{team_name}"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-metadata",
        yahoo_query.get_team_metadata,
        params={"team_id": team_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-metadata",
        Team,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_team_stats

test_get_team_stats(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of stats for chosen team by team ID for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_stats.

Source code in test/integration/test_api_team_data.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@pytest.mark.integration
def test_get_team_stats(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, team_id, team_name,
                        show_log_output):
    """Integration test for retrieval of stats for chosen team by team ID for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_stats`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / "teams" / f"{team_id}-{team_name}"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-stats",
        yahoo_query.get_team_stats,
        params={"team_id": team_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-stats",
        TeamPoints,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_team_stats_by_week

test_get_team_stats_by_week(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    chosen_week,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of stats for chosen team by team ID and by week for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_stats_by_week.

Source code in test/integration/test_api_team_data.py
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@pytest.mark.integration
def test_get_team_stats_by_week(yahoo_query, yahoo_data, data_dir, season, chosen_week, game_id, league_id, team_id,
                                team_name, show_log_output):
    """Integration test for retrieval of stats for chosen team by team ID and by week for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_stats_by_week`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / f"week_{chosen_week}"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-stats",
        yahoo_query.get_team_stats_by_week,
        params={"team_id": team_id, "chosen_week": chosen_week},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-stats",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_team_standings

test_get_team_standings(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of standings for chosen team by team ID for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_standings.

Source code in test/integration/test_api_team_data.py
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
@pytest.mark.integration
def test_get_team_standings(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, team_id, team_name,
                            show_log_output):
    """Integration test for retrieval of standings for chosen team by team ID for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_standings`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / "teams" / f"{team_id}-{team_name}"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-standings",
        yahoo_query.get_team_standings,
        params={"team_id": team_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-standings",
        TeamStandings,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_team_roster_by_week

test_get_team_roster_by_week(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    chosen_week,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of roster for chosen team by team ID and by week for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_roster_by_week.

Source code in test/integration/test_api_team_data.py
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
@pytest.mark.integration
def test_get_team_roster_by_week(yahoo_query, yahoo_data, data_dir, season, chosen_week, game_id, league_id, team_id,
                                 team_name, show_log_output):
    """Integration test for retrieval of roster for chosen team by team ID and by week for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_roster_by_week`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / f"week_{chosen_week}" / "rosters"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-roster_by_week",
        yahoo_query.get_team_roster_by_week,
        params={"team_id": team_id, "chosen_week": chosen_week},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-roster_by_week",
        Roster,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_team_roster_player_info_by_week

test_get_team_roster_player_info_by_week(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    chosen_week,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of roster with player info for chosen team by team ID and by week for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_roster_player_info_by_week.

Source code in test/integration/test_api_team_data.py
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
@pytest.mark.integration
def test_get_team_roster_player_info_by_week(yahoo_query, yahoo_data, data_dir, season, chosen_week, game_id,
                                             league_id, team_id, team_name, show_log_output):
    """Integration test for retrieval of roster with player info for chosen team by team ID and by week for chosen Yahoo
    fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_roster_player_info_by_week`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / f"week_{chosen_week}" / "rosters"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-roster-player_info_by_week",
        yahoo_query.get_team_roster_player_info_by_week,
        params={"team_id": team_id, "chosen_week": chosen_week},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-roster-player_info_by_week",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_team_roster_player_info_by_date

test_get_team_roster_player_info_by_date(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    chosen_date,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of roster with player info for chosen team by team ID and by date for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_roster_player_info_by_date.

Source code in test/integration/test_api_team_data.py
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
@pytest.mark.skip(
    reason="Skipping test_get_team_roster_player_info_by_date: retrieval by date supported by NHL/NBA/MLB, not NFL."
)
@pytest.mark.integration
def test_get_team_roster_player_info_by_date(yahoo_query, yahoo_data, data_dir, season, chosen_date, game_id,
                                             league_id, team_id, team_name, show_log_output):
    """Integration test for retrieval of roster with player info for chosen team by team ID and by date for chosen Yahoo
    fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_roster_player_info_by_date`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / str(chosen_date) / "rosters"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-roster-player_info_by_date",
        yahoo_query.get_team_roster_player_info_by_date,
        params={"team_id": team_id, "chosen_date": chosen_date},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-roster-player_info_by_date",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_team_roster_player_stats

test_get_team_roster_player_stats(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of roster with player info for chosen team by team ID and for chosen season for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_roster_player_stats.

Source code in test/integration/test_api_team_data.py
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
@pytest.mark.integration
def test_get_team_roster_player_stats(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, team_id,
                                      team_name, show_log_output):
    """Integration test for retrieval of roster with player info for chosen team by team ID and for chosen season for
    chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_roster_player_stats`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / "rosters"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-roster-player_stats",
        yahoo_query.get_team_roster_player_stats,
        params={"team_id": team_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-roster-player_stats",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_team_roster_player_stats_by_week

test_get_team_roster_player_stats_by_week(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    chosen_week,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of roster with player info for chosen team by team ID and by week for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_roster_player_stats_by_week.

Source code in test/integration/test_api_team_data.py
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
@pytest.mark.integration
def test_get_team_roster_player_stats_by_week(yahoo_query, yahoo_data, data_dir, season, chosen_week, game_id,
                                              league_id, team_id, team_name, show_log_output):
    """Integration test for retrieval of roster with player info for chosen team by team ID and by week for chosen Yahoo
    fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_roster_player_stats_by_week`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / f"week_{chosen_week}" / "rosters"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-roster-player_stats_by_week",
        yahoo_query.get_team_roster_player_stats_by_week,
        params={"team_id": team_id, "chosen_week": chosen_week},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-roster-player_stats_by_week",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_team_draft_results

test_get_team_draft_results(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of draft results for chosen team by team ID for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_draft_results.

Source code in test/integration/test_api_team_data.py
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
@pytest.mark.integration
def test_get_team_draft_results(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, team_id, team_name,
                                show_log_output):
    """Integration test for retrieval of draft results for chosen team by team ID for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_draft_results`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / "teams" / f"{team_id}-{team_name}"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-draft_results",
        yahoo_query.get_team_draft_results,
        params={"team_id": team_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-draft_results",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_team_matchups

test_get_team_matchups(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    league_id,
    team_id,
    team_name,
    show_log_output,
)

Integration test for retrieval of matchups for chosen team by team ID for chosen Yahoo fantasy league.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_team_matchups.

Source code in test/integration/test_api_team_data.py
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
@pytest.mark.integration
def test_get_team_matchups(yahoo_query, yahoo_data, data_dir, season, game_id, league_id, team_id, team_name,
                           show_log_output):
    """Integration test for retrieval of matchups for chosen team by team ID for chosen Yahoo fantasy league.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_team_matchups`.

    """
    new_data_dir = data_dir / str(season) / f"{game_id}.l.{league_id}" / "teams" / f"{team_id}-{team_name}"
    query_result_data = yahoo_data.save(
        f"{team_id}-{team_name}-matchups",
        yahoo_query.get_team_matchups,
        params={"team_id": team_id},
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        f"{team_id}-{team_name}-matchups",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_api_user_data

Pytest integration tests for Yahoo Fantasy Sports API user data.

Note

Tests saving and loading all Yahoo Fantasy Sports API user data.

Attributes:
  • logger (Logger) –

    Game data integration tests logger.

test_get_current_user

test_get_current_user(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of metadata for current logged-in Yahoo user.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_current_user.

Source code in test/integration/test_api_user_data.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@pytest.mark.integration
def test_get_current_user(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of metadata for current logged-in Yahoo user.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_current_user`.

    """
    new_data_dir = data_dir
    query_result_data = yahoo_data.save("user", yahoo_query.get_current_user, new_data_dir=new_data_dir)
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        "user",
        User,
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_user_games

test_get_user_games(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of game history for current logged-in Yahoo user.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_user_games.

Source code in test/integration/test_api_user_data.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@pytest.mark.integration
def test_get_user_games(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of game history for current logged-in Yahoo user.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_user_games`.

    """
    new_data_dir = data_dir
    query_result_data = yahoo_data.save(
        "user-games",
        yahoo_query.get_user_games,
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        "user-games",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_user_leagues_by_game_id

test_get_user_leagues_by_game_id(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of league history by game ID for current logged-in Yahoo user.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_user_leagues_by_game_key.

Source code in test/integration/test_api_user_data.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
@pytest.mark.skip(
    reason="Skipping get_user_leagues_by_game_key: current logged-in user must have leagues from test season/year."
)
@pytest.mark.integration
def test_get_user_leagues_by_game_id(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of league history by game ID for current logged-in Yahoo user.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_user_leagues_by_game_key`.

    """
    new_data_dir = data_dir
    query_result_data = yahoo_data.save(
        "user-leagues",
        yahoo_query.get_user_leagues_by_game_key,
        params={"game_key": game_id},
        new_data_dir=new_data_dir
    )

    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        "user-leagues",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data

test_get_user_teams

test_get_user_teams(
    yahoo_query,
    yahoo_data,
    data_dir,
    season,
    game_id,
    show_log_output,
)

Integration test for retrieval of teams for the current game for the current logged-in Yahoo user.

Note

Tests :func:~yfpy.query.YahooFantasySportsQuery.get_user_teams.

Source code in test/integration/test_api_user_data.py
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
@pytest.mark.integration
def test_get_user_teams(yahoo_query, yahoo_data, data_dir, season, game_id, show_log_output):
    """Integration test for retrieval of teams for the current game for the current logged-in Yahoo user.

    Note:
        Tests :func:`~yfpy.query.YahooFantasySportsQuery.get_user_teams`.

    """
    """Retrieve teams for all leagues for current logged-in user for current game.
    """
    new_data_dir = data_dir
    query_result_data = yahoo_data.save(
        "user-teams",
        yahoo_query.get_user_teams,
        new_data_dir=new_data_dir
    )
    if show_log_output:
        logger.info(prettify_data(query_result_data))

    loaded_result_data = yahoo_data.load(
        "user-teams",
        new_data_dir=new_data_dir,
        all_output_as_json_str=yahoo_query.all_output_as_json_str
    )
    if show_log_output:
        logger.info(prettify_data(loaded_result_data))

    assert query_result_data == loaded_result_data