#!/usr/bin/env python3 """快速测试脚本""" import os import sys sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) print("Step 1: Importing app...") try: from app import create_app, db print("OK: App imported") except Exception as e: print(f"ERROR: {e}") import traceback traceback.print_exc() sys.exit(1) print("Step 2: Importing neo4j driver...") try: from app.services.neo4j_driver import neo4j_driver print("OK: Neo4j driver imported") except Exception as e: print(f"ERROR: {e}") import traceback traceback.print_exc() sys.exit(1) print("Step 3: Creating app context...") try: app = create_app() print("OK: App created") except Exception as e: print(f"ERROR: {e}") import traceback traceback.print_exc() sys.exit(1) print("Step 4: Testing Neo4j connection...") try: with app.app_context(), neo4j_driver.get_session() as session: result = session.run("RETURN 1 as test").single() print(f"OK: Neo4j connection works, result={result['test']}") except Exception as e: print(f"ERROR: {e}") import traceback traceback.print_exc() sys.exit(1) print("Step 5: Testing PostgreSQL connection...") try: with app.app_context(): from sqlalchemy import text result = db.session.execute(text("SELECT 1")).scalar() print(f"OK: PostgreSQL connection works, result={result}") except Exception as e: print(f"ERROR: {e}") import traceback traceback.print_exc() sys.exit(1) print("\nAll basic tests passed!")