#!/usr/bin/env python """ Test runner script for SkyTalk API. This script can be run without pytest to validate basic functionality. """ import asyncio import sys from pathlib import Path # Add the app directory to Python path app_dir = Path(__file__).parent sys.path.insert(0, str(app_dir)) async def test_basic_setup(): """Test basic setup and imports.""" print("๐Ÿงช Testing basic setup...") try: from app.core.config import settings print(f"โœ… Config loaded: API key {'set' if settings.GOOGLE_API_KEY and settings.GOOGLE_API_KEY != 'your_google_api_key_here' else 'NOT set'}") from app.data.models import Session, Note, Link, StartSessionRequest print("โœ… All models imported successfully") from app.data.database import init_db, get_session print("โœ… Database modules imported successfully") from app.data.repositories import SessionRepository, NoteRepository, LinkRepository print("โœ… Repository modules imported successfully") except Exception as e: print(f"โŒ Import error: {e}") return False return True async def test_model_validation(): """Test model creation and validation.""" print("\n๐Ÿงช Testing model validation...") try: from app.data.models import StartSessionRequest, Session, Note import uuid # Test API models req = StartSessionRequest(topic="AI Ethics") print(f"โœ… StartSessionRequest: {req.topic}") # Test database models session = Session() print(f"โœ… Session created with ID: {session.id}") note = Note( title="Test Note", content="Test content", tags=["test"], session_id=session.id ) print(f"โœ… Note created with ID: {note.id}") except Exception as e: print(f"โŒ Model validation error: {e}") return False return True async def test_database_operations(): """Test database initialization and basic operations.""" print("\n๐Ÿงช Testing database operations...") try: from app.data.database import init_db, get_session from app.data.repositories import SessionRepository from app.data.models import Session # Initialize database await init_db() print("โœ… Database tables created") # Test repository operations async with get_session() as db: repo = SessionRepository(db) session = await repo.create(status="test") print(f"โœ… Session created via repository: {session.id}") retrieved = await repo.get(session.id) print(f"โœ… Session retrieved: {retrieved.status}") except Exception as e: print(f"โŒ Database operation error: {e}") return False return True async def main(): """Run all tests.""" print("๐Ÿš€ Running SkyTalk API validation tests...\n") tests = [ test_basic_setup, test_model_validation, test_database_operations ] passed = 0 total = len(tests) for test in tests: if await test(): passed += 1 else: break # Stop on first failure print(f"\n๐Ÿ“Š Test Results: {passed}/{total} passed") if passed == total: print("๐ŸŽ‰ All basic validation tests passed!") print("\nNext steps:") print("1. Run full test suite: pytest") print("2. Continue with Phase 3 implementation") else: print("โŒ Some tests failed. Please fix issues before continuing.") sys.exit(1) if __name__ == "__main__": asyncio.run(main())