Fix test suite failures and improve test infrastructure

## 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
This commit is contained in:
Claude
2025-11-18 14:11:59 +00:00
parent 14b3bc5773
commit 5097689967
5 changed files with 33 additions and 15 deletions

View File

@@ -67,8 +67,8 @@ class AnchorEvent(Base):
status = Column(String(20), nullable=False) # pending, confirmed, failed
error_message = Column(Text, nullable=True)
# Metadata
metadata = Column(Text, nullable=True) # JSON serialized
# Metadata (renamed from 'metadata' to avoid SQLAlchemy reserved attribute)
event_metadata = Column(Text, nullable=True) # JSON serialized
# Timestamps
created_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)