Spaces:
Running
Running
File size: 3,194 Bytes
2043365 2d94e01 2043365 2d94e01 2043365 2d94e01 2043365 2d94e01 2043365 2d94e01 |
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
#!/bin/bash
# Comprehensive test runner for Text Summarizer API
# This script runs all tests and provides detailed reporting
set -e # Exit on any error
echo "π§ͺ Text Summarizer API - Test Suite"
echo "===================================="
echo ""
# Change to project root
cd "$(dirname "$0")/.."
# Check if pytest is available
if ! command -v python &> /dev/null; then
echo "β Python not found. Please install Python to run tests."
exit 1
fi
if ! python -c "import pytest" &> /dev/null; then
echo "β pytest not found. Please install pytest to run tests."
echo " Run: pip install pytest pytest-asyncio"
exit 1
fi
# Function to run tests with different configurations
run_test_suite() {
local test_type="$1"
local test_args="$2"
local description="$3"
echo "π $description"
echo "----------------------------------------"
if python -m pytest $test_args; then
echo "β
$description - PASSED"
echo ""
return 0
else
echo "β $description - FAILED"
echo ""
return 1
fi
}
# Track overall success
overall_success=true
# Run different test suites
echo "π Running comprehensive test suite..."
echo ""
# 1. Unit tests (fast)
if ! run_test_suite "unit" "tests/test_services.py tests/test_config.py tests/test_schemas.py tests/test_errors.py tests/test_logging.py tests/test_middleware.py" "Unit Tests"; then
overall_success=false
fi
# 2. API tests
if ! run_test_suite "api" "tests/test_api.py tests/test_api_errors.py" "API Tests"; then
overall_success=false
fi
# 3. Integration tests
if ! run_test_suite "integration" "tests/test_502_prevention.py" "502 Prevention Tests"; then
overall_success=false
fi
# 4. Startup script tests
if ! run_test_suite "startup" "tests/test_startup_script.py" "Startup Script Tests"; then
overall_success=false
fi
# 5. Main application tests
if ! run_test_suite "main" "tests/test_main.py" "Main Application Tests"; then
overall_success=false
fi
# 6. All tests together (comprehensive)
echo "π Running All Tests Together"
echo "----------------------------------------"
if python -m pytest tests/ -v --tb=short; then
echo "β
All Tests Together - PASSED"
echo ""
else
echo "β All Tests Together - FAILED"
echo ""
overall_success=false
fi
# Final report
echo "π Test Summary"
echo "==============="
if [ "$overall_success" = true ]; then
echo "π ALL TESTS PASSED!"
echo ""
echo "β
Your code is ready for:"
echo " β’ Committing to git"
echo " β’ Deploying to production"
echo " β’ Code review"
echo ""
echo "π Text Summarizer API is production-ready!"
exit 0
else
echo "β SOME TESTS FAILED!"
echo ""
echo "π§ Please fix the failing tests before:"
echo " β’ Committing to git"
echo " β’ Deploying to production"
echo " β’ Code review"
echo ""
echo "π‘ Run individual test files to debug:"
echo " python -m pytest tests/test_services.py -v"
echo " python -m pytest tests/test_api.py -v"
echo " python -m pytest tests/test_502_prevention.py -v"
echo ""
exit 1
fi |