Files
computer/libs/python/core/tests/conftest.py
Elshoubky M 451c9c2c01 Add test infrastructure with CI/CD
- Add separate test directories for all 7 packages (core, agent, computer, computer-server, mcp-server, pylume, som)
- Create 30+ unit tests with mocks for external dependencies (liteLLM, PostHog, Computer)
- Add conftest.py fixtures for each package to enable isolated testing
- Implement GitHub Actions CI workflow with matrix strategy to test each package independently
- Add TESTING.md with comprehensive testing guide and architecture documentation
- Follow SOLID principles: SRP, Vertical Slice Architecture, and Testability as Design Signal

Note:
- No API keys required for unit tests
2025-10-21 18:58:40 -04:00

43 lines
1.2 KiB
Python

"""Pytest configuration and shared fixtures for core package tests.
This file contains shared fixtures and configuration for all core tests.
Following SRP: This file ONLY handles test setup/teardown.
"""
import pytest
from unittest.mock import Mock, AsyncMock, patch
@pytest.fixture
def mock_httpx_client():
"""Mock httpx.AsyncClient for API calls.
Use this fixture to avoid making real HTTP requests during tests.
"""
with patch("httpx.AsyncClient") as mock_client:
mock_instance = AsyncMock()
mock_client.return_value.__aenter__.return_value = mock_instance
yield mock_instance
@pytest.fixture
def mock_posthog():
"""Mock PostHog client for telemetry tests.
Use this fixture to avoid sending real telemetry during tests.
"""
with patch("posthog.Posthog") as mock_ph:
mock_instance = Mock()
mock_ph.return_value = mock_instance
yield mock_instance
@pytest.fixture
def disable_telemetry(monkeypatch):
"""Disable telemetry for tests that don't need it.
Use this fixture to ensure telemetry is disabled during tests.
"""
monkeypatch.setenv("CUA_TELEMETRY_DISABLED", "1")
yield