File size: 2,268 Bytes
3e7266f |
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 |
#!/usr/bin/env python3
"""
Quick test runner to verify the application works correctly.
"""
import subprocess
import sys
def run_command(cmd, description):
"""Run a command and return success status"""
print(f"\n{'='*60}")
print(f"Testing: {description}")
print(f"{'='*60}")
try:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
if result.returncode == 0:
print(f"β
SUCCESS: {description}")
if result.stdout:
print(f"Output: {result.stdout[:200]}...")
return True
else:
print(f"β FAILED: {description}")
print(f"Error: {result.stderr}")
return False
except subprocess.TimeoutExpired:
print(f"β° TIMEOUT: {description}")
return False
except Exception as e:
print(f"π₯ ERROR: {description} - {str(e)}")
return False
def main():
"""Run all tests"""
print("π Starting Application Test Suite")
tests = [
("python -c 'from app.main import app; print(\"FastAPI app imported successfully\")'",
"FastAPI App Import"),
("python -c 'from app.pipeline import RAGPipeline; print(\"RAG Pipeline imported successfully\")'",
"RAG Pipeline Import"),
("python -m pytest test_app.py::TestChatEndpoint::test_chat_endpoint_basic -q",
"Basic Chat Endpoint Test"),
("python -m pytest test_app.py::TestRAGFunction::test_rag_qa_with_loaded_pipeline -q",
"RAG Function Test"),
("python -m pytest test_app.py::TestToolsConfiguration::test_tools_structure -q",
"Tools Configuration Test"),
]
passed = 0
total = len(tests)
for cmd, desc in tests:
if run_command(cmd, desc):
passed += 1
print(f"\n{'='*60}")
print("TEST SUMMARY")
print(f"{'='*60}")
print(f"Passed: {passed}/{total}")
if passed == total:
print("π All tests passed! The application is working correctly.")
return 0
else:
print("β οΈ Some tests failed. Please check the output above.")
return 1
if __name__ == "__main__":
sys.exit(main()) |