opencompletion.com/tests/conftest.py
Russell Ballestrini 51b74be7d9 Fix YAML validator and activity file validation errors
- Updated validator terminal step detection to only flag truly terminal steps
- Fixed validator to accept integers and booleans in buckets (as supported by app.py)
- Fixed metadata_remove format in activity17 from dictionary to list of strings
- Added proper terminal section to activity3.yaml without questions/buckets
- Fixed missing restart transition and bucket in activity28
- Removed unused game_end transitions from battleship files
- Updated exit transitions to go directly to step_4 (goodbye step)
- Applied black formatting to validator code

All 30 activity YAML files now validate successfully with 0 errors and 0 warnings.
2025-08-10 19:38:50 -04:00

47 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""
pytest configuration and fixtures for OpenCompletion testing
Sets up common test environment variables and fixtures used across all tests.
"""
import os
import pytest
from unittest.mock import patch, MagicMock
# Set up test environment variables immediately at import time
TEST_ENV_VARS = {
"MODEL_ENDPOINT_1": "https://test.api",
"MODEL_NAME_1": "test-model",
"MODEL_KEY_1": "test-key",
}
# Apply environment variables immediately for import
os.environ.update(TEST_ENV_VARS)
@pytest.fixture(scope="session", autouse=True)
def setup_test_environment():
"""Set up test environment variables for all tests"""
with patch.dict(os.environ, TEST_ENV_VARS):
yield
@pytest.fixture
def mock_openai_client():
"""Mock OpenAI client for testing"""
mock_client = MagicMock()
mock_response = MagicMock()
mock_response.choices[0].message.content.strip.return_value = "test response"
mock_client.chat.completions.create.return_value = mock_response
return mock_client
@pytest.fixture
def mock_s3_client():
"""Mock S3 client for testing"""
mock_client = MagicMock()
mock_response = {"Body": MagicMock()}
mock_response["Body"].read.return_value.decode.return_value = "test: content"
mock_client.get_object.return_value = mock_response
return mock_client