- Add comprehensive testing framework with 67 test cases covering unit, integration, and functional testing - Create universal YAML validator supporting all activity types with validation for metadata operations, terminal steps, and Python syntax - Implement proper Makefile with venv management and test runners following unDRY principles for copy-paste engineering - Add requirements-test.txt for test dependencies separation - Configure pytest with conftest.py for proper environment variable management - Update CLAUDE.md with Makefile best practices - All 67 tests passing with proper mocking of external dependencies Testing coverage includes: • Unit tests (37): Core app functions, utilities, navigation, response handling • Integration tests (20): Complete activity workflows and error handling • Functional tests (9): Full battleship game scenarios and edge cases • YAML validator (17): Universal validation for all activity configurations
46 lines
No EOL
1.3 KiB
Python
46 lines
No EOL
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 |