#!/usr/bin/env python3
"""Test script to diagnose team name issues with CFBD API"""
import sys
import os
sys.path.insert(0, os.path.dirname(__file__))
from src.cfbd_api import get_team_games
from src.team_normalizer import normalize_team_name
from dotenv import load_dotenv
load_dotenv()
api_key = os.getenv("CFB_API_KEY")
if not api_key:
print("ERROR: CFB_API_KEY not found")
sys.exit(1)
test_teams = ["Alabama", "alabama", "Alabama Crimson Tide"]
year = 2024
print(f"Testing CFBD API with year {year}\n")
for team in test_teams:
print(f"Testing: '{team}'")
normalized = normalize_team_name(team)
print(f" Normalized: '{normalized}'")
games = get_team_games(api_key, team, year, "both")
if games is None:
print(f" Result: None (error)")
elif isinstance(games, list):
print(f" Result: {len(games)} games")
if len(games) > 0:
first = games[0]
print(f" First game: {first.get('home_team')} vs {first.get('away_team')} on {first.get('start_date')}")
else:
print(f" Result: {type(games)} - {games}")
print()