"""Test static file URLs"""
from app import create_app

app = create_app()

with app.test_request_context():
    from flask import url_for
    
    # Test the latest logo
    logo_path = "admin/logo/logo_6b1a632348fe485ba18183ad4052b18e.jpg"
    
    print(f"Database path: {logo_path}")
    print(f"URL: {url_for('static', filename=logo_path)}")
    
    # Check if file exists
    from pathlib import Path
    base = Path(__file__).resolve().parent / "static"
    full_path = base / logo_path
    print(f"File exists: {full_path.exists()}")
    print(f"Full path: {full_path}")
    
    # Test all asset types
    import mysql.connector
    conn = mysql.connector.connect(host='127.0.0.1', user='root', password='', database='event_ai')
    cursor = conn.cursor(dictionary=True)
    cursor.execute("SELECT type, image_path FROM admin_assets WHERE id IN (SELECT MAX(id) FROM admin_assets GROUP BY type)")
    latest = cursor.fetchall()
    print("\n=== Latest assets ===")
    for asset in latest:
        print(f"{asset['type']:10} {asset['image_path']:60} URL: {url_for('static', filename=asset['image_path'])}")
    cursor.close()
    conn.close()
