Files
LEDMatrix/test/test_games_to_show_config.py
Chuck ad8a652183 Fix leaderboard scrolling performance after PR #39 merge (#63)
* Fix leaderboard scrolling performance after PR #39 merge

- Restore leaderboard background updates that were accidentally removed
- Fix duration method call from get_dynamic_duration() back to get_duration()
- Restore proper fallback duration (600s instead of 60s) for leaderboard
- Add back sports manager updates that feed data to leaderboard
- Fix leaderboard defer_update priority to prevent scrolling lag

These changes restore the leaderboard's dynamic duration calculation
and ensure it gets proper background updates for smooth scrolling.

* Apply PR #60 leaderboard performance optimizations

- Change scroll_delay from 0.05s to 0.01s (100fps instead of 20fps)
- Remove conditional scrolling logic - scroll every frame for smooth animation
- Add FPS tracking and logging for performance monitoring
- Restore high-framerate scrolling that was working before PR #39 merge

These changes restore the smooth leaderboard scrolling performance
that was achieved in PR #60 but was lost during the PR #39 merge.

* Fix critical bugs identified in PR #39 review

- Fix record filtering logic bug: change away_record == set to away_record in set
- Fix incorrect sport specification: change 'nfl' to 'ncaa_fb' for NCAA Football data requests
- These bugs were causing incorrect data display and wrong sport data fetching

Addresses issues found by cursor bot in PR #39 review:
- Record filtering was always evaluating to False
- NCAA Football was fetching NFL data instead of college football data

* Enhance cache clearing implementation from PR #39

- Add detailed logging to cache clearing process for better visibility
- Log cache clearing statistics (memory entries and file count)
- Improve startup logging to show cache clearing and data refetch process
- Addresses legoguy1000's comment about preventing stale data issues

This enhances the cache clearing implementation that was added in PR #39
to help prevent legacy cache issues and stale data problems.

* continuing on base_classes - added baseball and api extractor since we don't use ESPN api for all sports

* tests

* fix missing duration

* ensure milb, mlb, ncaa bb are all using new baseball base class properly

* cursor rule to help with PR creation

* fix image call

* fix _scoreboard suffix on milb, MLB
2025-09-25 09:34:20 -04:00

128 lines
4.9 KiB
Python

#!/usr/bin/env python3
"""
Test script to verify that *_games_to_show configuration settings are working correctly
across all sports managers.
"""
import json
import sys
import os
# Add the src directory to the path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
def load_config():
"""Load the configuration file."""
config_path = os.path.join(os.path.dirname(__file__), '..', 'config', 'config.json')
with open(config_path, 'r') as f:
return json.load(f)
def test_config_values():
"""Test that config values are set correctly."""
config = load_config()
print("Testing *_games_to_show configuration values:")
print("=" * 50)
sports_configs = [
("NHL", config.get('nhl_scoreboard', {})),
("NBA", config.get('nba_scoreboard', {})),
("NFL", config.get('nfl_scoreboard', {})),
("NCAA Football", config.get('ncaa_fb_scoreboard', {})),
("NCAA Baseball", config.get('ncaa_baseball_scoreboard', {})),
("NCAA Basketball", config.get('ncaam_basketball_scoreboard', {})),
("MLB", config.get('mlb_scoreboard', {})),
("MiLB", config.get('milb_scoreboard', {})),
("Soccer", config.get('soccer_scoreboard', {}))
]
for sport_name, sport_config in sports_configs:
recent_games = sport_config.get('recent_games_to_show', 'NOT_SET')
upcoming_games = sport_config.get('upcoming_games_to_show', 'NOT_SET')
print(f"{sport_name:15} | Recent: {recent_games:2} | Upcoming: {upcoming_games:2}")
print("\nExpected behavior:")
print("- When recent_games_to_show = 1: Only show 1 most recent game")
print("- When upcoming_games_to_show = 1: Only show 1 next upcoming game")
print("- When values > 1: Show multiple games and rotate through them")
def test_manager_defaults():
"""Test that managers have correct default values."""
print("\n" + "=" * 50)
print("Testing manager default values:")
print("=" * 50)
# Test the default values that managers use when config is not set
manager_defaults = {
"NHL": {"recent": 5, "upcoming": 5},
"NBA": {"recent": 5, "upcoming": 5},
"NFL": {"recent": 5, "upcoming": 10},
"NCAA Football": {"recent": 5, "upcoming": 10},
"NCAA Baseball": {"recent": 5, "upcoming": 5},
"NCAA Basketball": {"recent": 5, "upcoming": 5},
"MLB": {"recent": 5, "upcoming": 10},
"MiLB": {"recent": 5, "upcoming": 10},
"Soccer": {"recent": 5, "upcoming": 5}
}
for sport_name, defaults in manager_defaults.items():
print(f"{sport_name:15} | Recent default: {defaults['recent']:2} | Upcoming default: {defaults['upcoming']:2}")
def test_config_consistency():
"""Test for consistency between config values and expected behavior."""
config = load_config()
print("\n" + "=" * 50)
print("Testing config consistency:")
print("=" * 50)
sports_configs = [
("NHL", config.get('nhl_scoreboard', {})),
("NBA", config.get('nba_scoreboard', {})),
("NFL", config.get('nfl_scoreboard', {})),
("NCAA Football", config.get('ncaa_fb_scoreboard', {})),
("NCAA Baseball", config.get('ncaa_baseball_scoreboard', {})),
("NCAA Basketball", config.get('ncaam_basketball_scoreboard', {})),
("MLB", config.get('mlb_scoreboard', {})),
("MiLB", config.get('milb_scoreboard', {})),
("Soccer", config.get('soccer_scoreboard', {}))
]
issues_found = []
for sport_name, sport_config in sports_configs:
recent_games = sport_config.get('recent_games_to_show')
upcoming_games = sport_config.get('upcoming_games_to_show')
if recent_games is None:
issues_found.append(f"{sport_name}: recent_games_to_show not set")
if upcoming_games is None:
issues_found.append(f"{sport_name}: upcoming_games_to_show not set")
if recent_games == 1:
print(f"{sport_name:15} | Recent: {recent_games} (Single game mode)")
elif recent_games > 1:
print(f"{sport_name:15} | Recent: {recent_games} (Multi-game rotation)")
else:
issues_found.append(f"{sport_name}: Invalid recent_games_to_show value: {recent_games}")
if upcoming_games == 1:
print(f"{sport_name:15} | Upcoming: {upcoming_games} (Single game mode)")
elif upcoming_games > 1:
print(f"{sport_name:15} | Upcoming: {upcoming_games} (Multi-game rotation)")
else:
issues_found.append(f"{sport_name}: Invalid upcoming_games_to_show value: {upcoming_games}")
if issues_found:
print("\nIssues found:")
for issue in issues_found:
print(f" - {issue}")
else:
print("\nNo configuration issues found!")
if __name__ == "__main__":
test_config_values()
test_manager_defaults()
test_config_consistency()