Initial commit: Virtual Board Member AI System foundation
This commit is contained in:
172
test_setup.py
Normal file
172
test_setup.py
Normal file
@@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple test script to verify the Virtual Board Member AI System setup.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add the app directory to the Python path
|
||||
sys.path.insert(0, str(Path(__file__).parent / "app"))
|
||||
|
||||
def test_imports():
|
||||
"""Test that all core modules can be imported."""
|
||||
print("🔍 Testing imports...")
|
||||
|
||||
try:
|
||||
from app.core.config import settings
|
||||
print("✅ Settings imported successfully")
|
||||
|
||||
from app.core.database import Base, get_db
|
||||
print("✅ Database modules imported successfully")
|
||||
|
||||
from app.core.logging import setup_logging, get_logger
|
||||
print("✅ Logging modules imported successfully")
|
||||
|
||||
from app.main import app
|
||||
print("✅ Main app imported successfully")
|
||||
|
||||
from app.models.user import User, UserRole
|
||||
print("✅ User model imported successfully")
|
||||
|
||||
return True
|
||||
except ImportError as e:
|
||||
print(f"❌ Import failed: {e}")
|
||||
return False
|
||||
|
||||
def test_configuration():
|
||||
"""Test configuration loading."""
|
||||
print("\n🔍 Testing configuration...")
|
||||
|
||||
try:
|
||||
from app.core.config import settings
|
||||
|
||||
# Test basic settings
|
||||
assert settings.APP_NAME == "Virtual Board Member AI"
|
||||
assert settings.APP_VERSION == "0.1.0"
|
||||
assert settings.ENVIRONMENT in ["development", "testing", "production"]
|
||||
|
||||
print("✅ Configuration loaded successfully")
|
||||
print(f" App Name: {settings.APP_NAME}")
|
||||
print(f" Version: {settings.APP_VERSION}")
|
||||
print(f" Environment: {settings.ENVIRONMENT}")
|
||||
print(f" Debug Mode: {settings.DEBUG}")
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"❌ Configuration test failed: {e}")
|
||||
return False
|
||||
|
||||
def test_logging():
|
||||
"""Test logging setup."""
|
||||
print("\n🔍 Testing logging...")
|
||||
|
||||
try:
|
||||
from app.core.logging import setup_logging, get_logger
|
||||
|
||||
# Setup logging
|
||||
setup_logging()
|
||||
logger = get_logger("test")
|
||||
|
||||
# Test logging
|
||||
logger.info("Test log message", test=True)
|
||||
print("✅ Logging setup successful")
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"❌ Logging test failed: {e}")
|
||||
return False
|
||||
|
||||
def test_fastapi_app():
|
||||
"""Test FastAPI application creation."""
|
||||
print("\n🔍 Testing FastAPI application...")
|
||||
|
||||
try:
|
||||
from app.main import app
|
||||
|
||||
# Test basic app properties
|
||||
assert app.title == "Virtual Board Member AI"
|
||||
assert app.version == "0.1.0"
|
||||
|
||||
print("✅ FastAPI application created successfully")
|
||||
print(f" Title: {app.title}")
|
||||
print(f" Version: {app.version}")
|
||||
print(f" Debug: {app.debug}")
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"❌ FastAPI test failed: {e}")
|
||||
return False
|
||||
|
||||
def test_project_structure():
|
||||
"""Test that required directories and files exist."""
|
||||
print("\n🔍 Testing project structure...")
|
||||
|
||||
required_files = [
|
||||
"pyproject.toml",
|
||||
"env.example",
|
||||
"docker-compose.dev.yml",
|
||||
"Dockerfile.dev",
|
||||
"README.md",
|
||||
"DEVELOPMENT_PLAN.md",
|
||||
"app/main.py",
|
||||
"app/core/config.py",
|
||||
"app/core/database.py",
|
||||
"app/core/logging.py",
|
||||
"app/api/v1/api.py",
|
||||
"app/models/user.py",
|
||||
]
|
||||
|
||||
missing_files = []
|
||||
for file_path in required_files:
|
||||
if not Path(file_path).exists():
|
||||
missing_files.append(file_path)
|
||||
else:
|
||||
print(f"✅ {file_path}")
|
||||
|
||||
if missing_files:
|
||||
print(f"❌ Missing files: {missing_files}")
|
||||
return False
|
||||
|
||||
print("✅ All required files present")
|
||||
return True
|
||||
|
||||
def main():
|
||||
"""Run all tests."""
|
||||
print("🚀 Testing Virtual Board Member AI System Setup")
|
||||
print("=" * 50)
|
||||
|
||||
tests = [
|
||||
test_project_structure,
|
||||
test_imports,
|
||||
test_configuration,
|
||||
test_logging,
|
||||
test_fastapi_app,
|
||||
]
|
||||
|
||||
passed = 0
|
||||
total = len(tests)
|
||||
|
||||
for test in tests:
|
||||
if test():
|
||||
passed += 1
|
||||
print()
|
||||
|
||||
print("=" * 50)
|
||||
print(f"📊 Test Results: {passed}/{total} tests passed")
|
||||
|
||||
if passed == total:
|
||||
print("🎉 All tests passed! The setup is working correctly.")
|
||||
print("\n📝 Next steps:")
|
||||
print(" 1. Copy env.example to .env and configure your settings")
|
||||
print(" 2. Run: docker-compose -f docker-compose.dev.yml up -d")
|
||||
print(" 3. Install dependencies: poetry install")
|
||||
print(" 4. Start the application: poetry run uvicorn app.main:app --reload")
|
||||
return 0
|
||||
else:
|
||||
print("❌ Some tests failed. Please check the errors above.")
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user