- Switched from psycopg2 to asyncpg for async SQLAlchemy support - Fixed router registration in main.py - removed duplicate prefixes - Added user_data export to routers/__init__.py - Refactored decks router to use DeckManager service layer - Integrated FuzzyCardMatcher into card_router search endpoints - Made WishlistCreate.card_id optional for proper schema validation - Set PostgreSQL password and configured scram-sha-256 auth - Updated alembic.ini to use local PostgreSQL instead of Docker hostname - Created generic_schemas.py for reusable schema patterns - Added test_routers.py and test_schema_validation.py test files - All 6 Alembic migrations applied successfully (37 tables created) - Application running on port 8000 with all services connected
73 lines
2.2 KiB
Python
73 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Test router imports and FastAPI app creation."""
|
|
import sys
|
|
import traceback
|
|
|
|
def test_router_imports():
|
|
"""Test that all routers can be imported."""
|
|
print("Testing router imports...")
|
|
try:
|
|
from app.routers import *
|
|
print("✅ All routers imported successfully")
|
|
return True
|
|
except Exception as e:
|
|
print(f"❌ Router import error: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
def test_fastapi_app():
|
|
"""Test that FastAPI app can be created."""
|
|
print("\nTesting FastAPI app creation...")
|
|
try:
|
|
from app.main import app
|
|
print("✅ FastAPI app created successfully")
|
|
print(f" App title: {app.title}")
|
|
print(f" App version: {app.version}")
|
|
return True
|
|
except Exception as e:
|
|
print(f"❌ FastAPI app creation error: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
def test_schema_imports():
|
|
"""Test that schemas are properly imported."""
|
|
print("\nTesting schema imports...")
|
|
try:
|
|
from app.schemas import (
|
|
MessageResponse, CountResponse,
|
|
CardCollectionCreate, CardCollectionResponse,
|
|
WishlistCreate, WishlistResponse,
|
|
)
|
|
print("✅ Schema imports successful")
|
|
return True
|
|
except Exception as e:
|
|
print(f"❌ Schema import error: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
print("=" * 60)
|
|
print("Phase 4: Router Layer Testing")
|
|
print("=" * 60)
|
|
|
|
results = []
|
|
results.append(("Router Imports", test_router_imports()))
|
|
results.append(("FastAPI App", test_fastapi_app()))
|
|
results.append(("Schema Imports", test_schema_imports()))
|
|
|
|
print("\n" + "=" * 60)
|
|
print("Test Results Summary")
|
|
print("=" * 60)
|
|
for test_name, passed in results:
|
|
status = "✅ PASS" if passed else "❌ FAIL"
|
|
print(f"{test_name:20} {status}")
|
|
|
|
all_passed = all(result[1] for result in results)
|
|
print("\n" + ("=" * 60))
|
|
if all_passed:
|
|
print("✅ ALL TESTS PASSED")
|
|
sys.exit(0)
|
|
else:
|
|
print("❌ SOME TESTS FAILED")
|
|
sys.exit(1)
|