Introduce typed config objects, optional adapter injection, and .env loading to simplify testing while preserving env-based defaults for production usage. Co-authored-by: Cursor <[email protected]>
28 lines
834 B
Python
28 lines
834 B
Python
"""Unit test fixtures for mocked adapters."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
import pytest
|
|
import redis
|
|
from minio import Minio
|
|
|
|
from python_repositories.adapters.minio_adapter import MinioAdapter
|
|
from python_repositories.adapters.redis_adapter import RedisAdapter
|
|
from tests.conftest import TEST_MINIO_CONFIG, TEST_REDIS_CONFIG
|
|
|
|
|
|
@pytest.fixture
|
|
def redis_adapter() -> RedisAdapter:
|
|
"""Provide a RedisAdapter with an injected mock client."""
|
|
mock_client = MagicMock(spec=redis.Redis)
|
|
return RedisAdapter(config=TEST_REDIS_CONFIG, client=mock_client)
|
|
|
|
|
|
@pytest.fixture
|
|
def minio_adapter() -> MinioAdapter:
|
|
"""Provide a MinioAdapter with an injected mock client."""
|
|
mock_client = MagicMock(spec=Minio)
|
|
return MinioAdapter(config=TEST_MINIO_CONFIG, client=mock_client)
|