#!/usr/bin/env python3
"""
Simple test script for the PDF KB frontend
Tests basic API endpoints and functionality
"""
import asyncio
import sys
from pathlib import Path
from pdfkb.config import ServerConfig
from pdfkb.main import PDFKnowledgebaseServer
# Add the src directory to Python path
sys.path.insert(0, str(Path(__file__).parent.parent))
async def test_api_endpoints():
"""Test the basic API endpoints"""
# Initialize server
config = ServerConfig.from_env()
server = PDFKnowledgebaseServer(config)
try:
await server.initialize()
# Test health endpoint
print("Testing health endpoint...")
# This would require more setup to actually test HTTP endpoints
print("β Server initialized successfully")
# Test status endpoint
print("Testing system status...")
print(f"β Document cache initialized: {len(server._document_cache)} documents")
# Test vector store
print("Testing vector store...")
print("β Vector store initialized")
print("\nπ Basic backend functionality test passed!")
print("\nTo test the full web interface:")
print("1. Run the server: python -m pdfkb.web_server")
print("2. Open http://localhost:8080 in your browser")
print("3. The frontend should load and connect via WebSocket")
except Exception as e:
print(f"β Test failed: {e}")
raise
finally:
await server.shutdown()
if __name__ == "__main__":
asyncio.run(test_api_endpoints())