Files

49 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2026-10-04 18:24:18 -04:00
#!/bin/bash
# Script to test the process_image_analysis function in db.py
# This script will run the function and stop on errors.
# Define the path to the Python script and the image to process
# PYTHON_SCRIPT="src/db.py"
# Replace with the actual image path
IMAGE_PATH="/home/kfl/dev/git/avdb-py-v1/img/TESTIMG/TESTIMG.jpeg"
# Function to run the test
test_process_image_analysis() {
echo "Starting test for process_image_analysis..."
# Run the Python script and capture the output
output=$(python3 -c "
import sys
sys.path.append('src')
from db import DBOps, DBConnection
# Initialize the database connection
db_conn = DBConnection('testdb')
db_ops = DBOps(db_conn)
# Run the process_image_analysis function
try:
# raise(ValueError('testerr'))
db_ops.process_image_analysis('$IMAGE_PATH')
print('process_image_analysis completed successfully.')
except Exception as e:
print(f'Error in process_image_analysis: {e}')
sys.exit(1)
" 2>&1 | tee error_log.txt
)
# Check the output for errors
if [[ "$output" == *"Error"* ]]; then
echo "Test failed: $output"
exit 1
else
echo "Test passed: $output"
fi
}
# Run the test
test_process_image_analysis
# Exit with the appropriate status
# exit $?