"""
Quick endpoint test to verify what's accessible
"""

import requests
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def test_endpoints():
    """Test various endpoints to see what's working"""
    
    base_url = "http://localhost:5000"
    endpoints = [
        "/",
        "/auth/register",
        "/auth/login", 
        "/dashboard",
        "/jobs",
        "/api",
        "/api/health"
    ]
    
    logger.info("=" * 60)
    logger.info("ENDPOINT AVAILABILITY TEST")
    logger.info("=" * 60)
    
    working = []
    not_working = []
    
    for endpoint in endpoints:
        url = f"{base_url}{endpoint}"
        try:
            response = requests.get(url, timeout=2)
            status = response.status_code
            if status in [200, 302]:
                logger.info(f"✓ {endpoint} - Status: {status}")
                working.append(endpoint)
            else:
                logger.info(f"✗ {endpoint} - Status: {status}")
                not_working.append(f"{endpoint} ({status})")
        except requests.exceptions.Timeout:
            logger.info(f"✗ {endpoint} - TIMEOUT")
            not_working.append(f"{endpoint} (timeout)")
        except requests.exceptions.ConnectionError:
            logger.info(f"✗ {endpoint} - CONNECTION ERROR")
            not_working.append(f"{endpoint} (connection error)")
        except Exception as e:
            logger.info(f"✗ {endpoint} - ERROR: {e}")
            not_working.append(f"{endpoint} (error)")
    
    logger.info("\n" + "=" * 60)
    logger.info(f"SUMMARY: {len(working)} working, {len(not_working)} not working")
    
    if working:
        logger.info("\n✓ Working endpoints:")
        for endpoint in working:
            logger.info(f"  - {endpoint}")
    
    if not_working:
        logger.info("\n✗ Not working:")
        for item in not_working:
            logger.info(f"  - {item}")
    
    logger.info("=" * 60)

if __name__ == "__main__":
    test_endpoints()
