chore: Update backend test command and add test runner script
Some checks failed
CI / skip-ci-check (push) Successful in 1m27s
CI / skip-ci-check (pull_request) Successful in 1m26s
CI / python-lint (push) Has been cancelled
CI / test-backend (push) Has been cancelled
CI / build (push) Has been cancelled
CI / secret-scanning (push) Has been cancelled
CI / dependency-scan (push) Has been cancelled
CI / sast-scan (push) Has been cancelled
CI / workflow-summary (push) Has been cancelled
CI / lint-and-type-check (push) Has been cancelled
CI / lint-and-type-check (pull_request) Successful in 2m5s
CI / python-lint (pull_request) Successful in 1m52s
CI / test-backend (pull_request) Successful in 3m19s
CI / build (pull_request) Successful in 2m24s
CI / secret-scanning (pull_request) Successful in 1m41s
CI / dependency-scan (pull_request) Successful in 1m32s
CI / sast-scan (pull_request) Successful in 2m43s
CI / workflow-summary (pull_request) Successful in 1m26s

This commit modifies the backend test command in `package.json` to skip DeepFace during tests by setting the `SKIP_DEEPFACE_IN_TESTS` environment variable. Additionally, a new `run_tests.sh` script is introduced to streamline the testing process, ensuring the virtual environment is set up and dependencies are installed before running the tests. These changes enhance the testing workflow and improve reliability.
This commit is contained in:
Tanya 2026-01-07 15:23:16 -05:00
parent 364974141d
commit 1bf7cdf4ab
3 changed files with 48 additions and 2 deletions

View File

@ -18,7 +18,7 @@
"type-check:viewer": "npm run type-check --prefix viewer-frontend",
"lint:python": "flake8 backend --max-line-length=100 --ignore=E501,W503 || true",
"lint:python:syntax": "find backend -name '*.py' -exec python -m py_compile {} \\;",
"test:backend": "export PYTHONPATH=$(pwd) && source venv/bin/activate && python3 -m pytest tests/ -v || python3 -m pytest tests/ -v",
"test:backend": "export PYTHONPATH=$(pwd) && export SKIP_DEEPFACE_IN_TESTS=1 && ./venv/bin/python3 -m pytest tests/ -v",
"test:all": "npm run test:backend",
"ci:local": "npm run lint:all && npm run type-check:viewer && npm run lint:python && npm run test:backend && npm run build:all",
"deploy:dev": "npm run build:all && echo '✅ Build complete. Ready for deployment to dev server (10.0.10.121)'",

View File

@ -1,6 +1,6 @@
fastapi==0.115.0
uvicorn[standard]==0.30.6
pydantic==2.9.1
pydantic[email]==2.9.1
SQLAlchemy==2.0.36
psycopg2-binary==2.9.9
redis==5.0.8

46
run_tests.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/bash
# Simple test runner script for PunimTag backend tests
set -e
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}🧪 Running PunimTag Backend Tests${NC}"
echo ""
# Set environment variables
export PYTHONPATH=$(pwd)
export SKIP_DEEPFACE_IN_TESTS=1
# Check if venv exists
if [ ! -d "venv" ]; then
echo -e "${RED}❌ Virtual environment not found. Please create it first:${NC}"
echo " python3 -m venv venv"
echo " source venv/bin/activate"
echo " pip install -r requirements.txt"
exit 1
fi
# Check if pytest is installed
if ! ./venv/bin/python3 -m pytest --version > /dev/null 2>&1; then
echo -e "${YELLOW}⚠️ pytest not found. Installing dependencies...${NC}"
./venv/bin/pip install -r requirements.txt
fi
echo -e "${GREEN}✅ Environment ready${NC}"
echo ""
echo "Running tests..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Run tests with clear output
./venv/bin/python3 -m pytest tests/ -v --tb=short
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "${GREEN}✅ Tests completed${NC}"