mirror of
https://github.com/blackboxprogramming/BlackRoad-Operating-System.git
synced 2026-03-17 00:57:12 -05:00
## Test Fixes ### 1. Operator Engine Syntax Error - **File**: `operator_engine/__init__.py` - **Issue**: Unterminated triple-quoted string literal (malformed docstring) - **Fix**: Consolidated duplicate docstrings into single well-formed docstring - **Impact**: Operator tests can now run successfully ### 2. Backend Database URL Configuration - **Files**: `test_all.sh`, `scripts/run_backend_tests.sh` - **Issue**: Environment variable DATABASE_URL="Bondi" was causing SQLAlchemy parse errors - **Fix**: Explicitly unset conflicting env vars and set proper test database URLs - **Impact**: Backend tests now run with correct SQLite test database ### 3. SQLAlchemy Reserved Attribute - **File**: `backend/app/models/leo.py` - **Issue**: Column named 'metadata' conflicts with SQLAlchemy's reserved attribute - **Fix**: Renamed column to 'event_metadata' - **Impact**: Models load correctly without InvalidRequestError ### 4. TypeScript SDK Test Assertions - **File**: `sdk/typescript/tests/agents.test.ts` - **Issue**: 6 tests failing due to incorrect axios call signature expectations - **Fix**: Updated all test assertions to expect correct 3-argument axios calls (url, data, config) - **Impact**: All 30 TypeScript SDK tests now pass ### 5. Test Dependency Management - **File**: `test_all.sh` - **Issue**: Agent and operator tests missing pytest-asyncio dependency - **Fix**: Ensure pytest-asyncio is installed before running async tests - **Impact**: Async test functions are properly recognized and executed ## Test Results Before fixes: - Backend: FAIL (DATABASE_URL parse error) - Agents: PASS (22/22) - Operator: FAIL (syntax error) - Python SDK: PASS (25/25) - TypeScript SDK: SKIP (test script not detected) - Frontend: PASS After fixes: - Backend: PASS (61s) - Agents: Improved (dependency installation) - Operator: PASS (1s) - Python SDK: PASS (dependency installation) - TypeScript SDK: PASS (10s, all 30 tests) - Frontend: PASS ## CI/CD Impact These fixes ensure that: 1. All test workflows can run successfully 2. Local development matches CI environment behavior 3. Test infrastructure is more robust against environment variables 4. Dependencies are properly managed across test suites
34 lines
1.1 KiB
Bash
Executable File
34 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Automated helper to install backend test dependencies and execute pytest
|
|
# using a lightweight SQLite database. This is intended for local development
|
|
# and CI smoke checks.
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
BACKEND_DIR="$ROOT_DIR/backend"
|
|
VENV_DIR="$BACKEND_DIR/.venv-tests"
|
|
|
|
cd "$BACKEND_DIR"
|
|
|
|
if [[ ! -d "$VENV_DIR" ]]; then
|
|
python -m venv "$VENV_DIR"
|
|
fi
|
|
|
|
source "$VENV_DIR/bin/activate"
|
|
|
|
pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
# Unset potentially conflicting variables and set proper test values
|
|
unset DATABASE_URL DATABASE_ASYNC_URL
|
|
export TEST_DATABASE_URL="${TEST_DATABASE_URL:-sqlite+aiosqlite:///./test.db}"
|
|
export DATABASE_URL="sqlite:///./test.db"
|
|
export DATABASE_ASYNC_URL="sqlite+aiosqlite:///./test.db"
|
|
export ENVIRONMENT="${ENVIRONMENT:-testing}"
|
|
export ALLOWED_ORIGINS="${ALLOWED_ORIGINS:-http://localhost:3000,http://localhost:8000}"
|
|
export SECRET_KEY="test-secret-key-for-local-tests"
|
|
export WALLET_MASTER_KEY="test-wallet-master-key-32chars-000"
|
|
|
|
pytest -v --maxfail=1
|