Fix test script to handle missing game data keys

- Added safe key access using .get() method with defaults
- Added display of available keys in game data for debugging
- Added sport field display to help identify data structure
- This prevents KeyError when game data structure changes
This commit is contained in:
ChuckBuilds
2025-08-18 19:09:50 -05:00
parent 9f00124fad
commit e4b3adb867

View File

@@ -64,13 +64,15 @@ def test_dynamic_duration():
if odds_ticker.games_data: if odds_ticker.games_data:
print("\nSample game data:") print("\nSample game data:")
for i, game in enumerate(odds_ticker.games_data[:3]): # Show first 3 games for i, game in enumerate(odds_ticker.games_data[:3]): # Show first 3 games
print(f" Game {i+1}: {game['away_team']} @ {game['home_team']}") print(f" Game {i+1}: {game.get('away_team', 'Unknown')} @ {game.get('home_team', 'Unknown')}")
print(f" Time: {game['start_time']}") print(f" Time: {game.get('start_time', 'Unknown')}")
print(f" League: {game['league']}") print(f" League: {game.get('league', 'Unknown')}")
print(f" Sport: {game.get('sport', 'Unknown')}")
if game.get('odds'): if game.get('odds'):
print(f" Has odds: Yes") print(f" Has odds: Yes")
else: else:
print(f" Has odds: No") print(f" Has odds: No")
print(f" Available keys: {list(game.keys())}")
print() print()
# Check dynamic duration calculation # Check dynamic duration calculation