-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_backend.py
More file actions
75 lines (60 loc) · 2.23 KB
/
test_backend.py
File metadata and controls
75 lines (60 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
"""
Quick test to verify the backend starts without errors
"""
import sys
import os
from pathlib import Path
# Add current directory to path
sys.path.insert(0, str(Path(__file__).parent))
print("🔍 Testing backend startup...")
try:
# Test basic imports
print("📦 Testing imports...")
from flask import Flask
print(" ✅ Flask imported")
from flask_cors import CORS
print(" ✅ Flask-CORS imported")
from flask_sqlalchemy import SQLAlchemy
print(" ✅ Flask-SQLAlchemy imported")
# Test environment loading
print("📝 Testing environment...")
from dotenv import load_dotenv
load_dotenv()
port = os.getenv('PORT', '5000')
print(f" ✅ PORT configured: {port}")
# Test AI model imports (they might fail, but shouldn't crash)
print("🤖 Testing AI model imports...")
try:
from ai_models.github_analyzer import GitHubAnalyzer
print(" ✅ GitHubAnalyzer imported")
except Exception as e:
print(f" ⚠️ GitHubAnalyzer import warning: {e}")
try:
from ai_models.documentation_generator import DocumentationGenerator
print(" ✅ DocumentationGenerator imported")
except Exception as e:
print(f" ⚠️ DocumentationGenerator import warning: {e}")
try:
from ai_models.rag_pipeline import RAGPipeline
print(" ✅ RAGPipeline imported")
except Exception as e:
print(f" ⚠️ RAGPipeline import warning: {e}")
# Test app creation (without running)
print("🚀 Testing app creation...")
from app import app, db
print(" ✅ App created successfully")
with app.app_context():
try:
db.create_all()
print(" ✅ Database initialized")
except Exception as e:
print(f" ⚠️ Database warning: {e}")
print(f"\n✨ Backend test completed successfully!")
print(f"🌐 Backend should start on: http://localhost:{port}")
print(f"🔗 Frontend proxy should point to: http://localhost:{port}")
except Exception as e:
print(f"\n❌ Backend test failed: {e}")
import traceback
print(f"📚 Full traceback:\n{traceback.format_exc()}")
sys.exit(1)