#!/bin/bash # Start the Flask application in the background python src/unified_web_ui/app.py & APP_PID=$! # Wait for the application to start echo "Waiting for application to start..." sleep 10 # Check if the application is running if ! ps -p $APP_PID > /dev/null then echo "Application failed to start." exit 1 fi # Run the curl tests echo "Running curl tests..." http_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/) echo "Main page status code: $http_code" if [ "$http_code" != "200" ]; then echo "Main page test failed." fi http_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/get_fps) echo "get_fps status code: $http_code" if [ "$http_code" != "200" ]; then echo "get_fps test failed." fi matrix_data='{"matrix":[' for i in {1..5}; do matrix_data+='[' for j in {1..5}; do matrix_data+='{"ww":0,"cw":0,"blue":0}' if [ $j -lt 5 ]; then matrix_data+=',' fi done matrix_data+=']' if [ $i -lt 5 ]; then matrix_data+=',' fi done matrix_data+=']}' http_code=$(curl -s -o /dev/null -w "%{http_code}" -X POST -H "Content-Type: application/json" -d "$matrix_data" http://localhost:5000/set_matrix) echo "set_matrix status code: $http_code" if [ "$http_code" != "200" ]; then echo "set_matrix test failed." fi # Run the pytest tests echo "Running pytest tests..." pytest src/unified_web_ui/tests/ # Kill the Flask application kill $APP_PID