Spaces:
Running
Running
| from app.utils import ( | |
| get_all_models_options, | |
| get_all_tournaments_options, | |
| get_all_matches_in_tournament, | |
| get_players, | |
| get_player, | |
| ) | |
| def test_get_all_models_options(): | |
| """ | |
| Test the get_all_models_options function. | |
| """ | |
| # Call the function | |
| models = get_all_models_options() | |
| # Check expected session state updates | |
| assert len(models) > 0, "Expected non-empty list of models" | |
| assert all('name' in model for model in models), "Expected 'name' key in each model dictionary" | |
| def test_get_all_tournaments_options(): | |
| """ | |
| Test the get_all_tournaments_options function. | |
| """ | |
| # Call the function | |
| tournaments = get_all_tournaments_options() | |
| # Check expected session state updates | |
| assert len(tournaments) > 0, "Expected non-empty list of tournaments" | |
| assert all('name' in tournament for tournament in tournaments), "Expected 'name' key in each tournament dictionary" | |
| def test_get_all_matches_in_tournament(): | |
| """ | |
| Test the get_all_matches_in_tournament function. | |
| """ | |
| # Call the function | |
| matches = get_all_matches_in_tournament(tournament="BMW Open", year=2025) | |
| # Check expected session state updates | |
| assert len(matches) > 0, "Expected non-empty list of matches" | |
| assert all('fk_winner_id' in match for match in matches), "Expected 'fk_winner_id' key in each match dictionary" | |
| assert all('fk_loser_id' in match for match in matches), "Expected 'fk_loser_id' key in each match dictionary" | |
| def test_get_players(): | |
| """ | |
| Test the get_players function. | |
| """ | |
| # Call the function | |
| players = get_players(ids=[103, 104]) | |
| # Check expected session state updates | |
| assert len(players) > 0, "Expected non-empty list of players" | |
| assert all('id' in player for player in players.values()), "Expected 'id' key in each player dictionary" | |
| assert all('name' in player for player in players.values()), "Expected 'name' key in each player dictionary" | |
| def test_get_player(): | |
| """ | |
| Test the get_player function. | |
| """ | |
| # Call the function | |
| player = get_player(player_id=103) | |
| # Check expected session state updates | |
| assert player is not None, "Expected non-empty player data" | |
| assert 'id' in player, "Expected 'id' key in player dictionary" | |
| assert 'name' in player, "Expected 'name' key in player dictionary" | |