| """Integration test script: attempts to connect to Neo4j and Faiss index. | |
| This script is safe: it catches missing libraries and reports status. | |
| """ | |
| import sys | |
| import traceback | |
| def try_neo4j(): | |
| try: | |
| from backend.adapters.graph_adapter import Neo4jAdapter | |
| print("Neo4jAdapter loaded") | |
| a = Neo4jAdapter() | |
| if not a.is_available(): | |
| print("Neo4j driver not available or connection not established") | |
| return | |
| # create test node | |
| res = a.run("CREATE (n:Test {name:$name}) RETURN id(n) as id", name="integration_test") | |
| print("Neo4j create node result:", res) | |
| a.close() | |
| except Exception as e: | |
| print("Neo4j test failed:") | |
| traceback.print_exc() | |
| def try_faiss(): | |
| try: | |
| from backend.adapters.vector_adapter_full import FaissIndex | |
| print("FaissIndex available") | |
| dim = 32 | |
| idx = FaissIndex(dim) | |
| vec = [float(i) for i in range(dim)] | |
| idx.upsert("u1", vec) | |
| results = idx.search(vec, top_k=1) | |
| print("Faiss search results:", results) | |
| except Exception as e: | |
| print("Faiss test failed or faiss not installed:") | |
| traceback.print_exc() | |
| def main(): | |
| print("Running integration tests...") | |
| try_neo4j() | |
| try_faiss() | |
| if __name__ == '__main__': | |
| main() | |