#!/usr/bin/env python3 """Quick test script for AARS backend - run locally without Docker""" import os import sys # Add backend to path sys.path.insert(0, os.path.dirname(__file__)) # Generate secret if missing if not os.path.exists("secret.py"): with open("secret.py", "w") as f: f.write(f"JWT_SECRET = 'dev-secret-{os.urandom(16).hex()}'\n") # Import and run from database import init_db, SessionLocal from models import User print("๐Ÿงช Testing AARS Backend...") print() # Test 1: Database init print("1๏ธโƒฃ Testing database initialization...") try: init_db() print(" โœ… Database initialized") except Exception as e: print(f" โŒ Database init failed: {e}") sys.exit(1) # Test 2: Check admin user print("2๏ธโƒฃ Testing admin user...") try: db = SessionLocal() admin = db.query(User).filter(User.email == "admin@aars.hk").first() if admin: print(f" โœ… Admin exists: {admin.email}") else: print(" โš ๏ธ Admin not found") db.close() except Exception as e: print(f" โŒ Query failed: {e}") sys.exit(1) # Test 3: Test password hashing print("3๏ธโƒฃ Testing password hashing...") try: from database import get_password_hash, verify_password pw_hash = get_password_hash("test123") assert verify_password("test123", pw_hash) print(" โœ… Password hashing works") except Exception as e: print(f" โŒ Password hashing failed: {e}") sys.exit(1) print() print("๐ŸŽ‰ All basic tests passed!") print() print("To run the backend:") print(" cd backend") print(" pip install -r requirements.txt") print(" uvicorn main:app --reload --port 8000") print() print("Then visit: http://localhost:8000") print("API docs: http://localhost:8000/docs")