| |
| """ |
| 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()) |