""" Pytest configuration and fixtures for service adapters tests """ import pytest from fastapi.testclient import TestClient from unittest.mock import patch from main import app @pytest.fixture def client(): """Provide a test client for the FastAPI app""" return TestClient(app) @pytest.fixture def mock_services_config(): """Mock services configuration for testing""" return { "home_assistant": { "enabled": True, "url": "http://homeassistant.local:8123", "token": "test_token" }, "frigate": { "enabled": True, "url": "http://frigate.local:5000" }, "immich": { "enabled": False, "url": "http://immich.local:2283", "api_key": "test_key" } } @pytest.fixture def sample_ha_entities(): """Sample Home Assistant entities for testing""" return { "sensor.temperature": { "entity_id": "sensor.temperature", "state": "22.5", "attributes": { "unit_of_measurement": "°C", "friendly_name": "Temperature" } }, "light.living_room": { "entity_id": "light.living_room", "state": "on", "attributes": { "friendly_name": "Living Room Light" } } } @pytest.fixture def sample_frigate_events(): """Sample Frigate events for testing""" return { "events": [ { "id": "event_123", "timestamp": "2024-01-01T12:00:00Z", "camera": "front_door", "label": "person", "confidence": 0.95 }, { "id": "event_456", "timestamp": "2024-01-01T12:05:00Z", "camera": "back_yard", "label": "car", "confidence": 0.87 } ] } @pytest.fixture def sample_immich_assets(): """Sample Immich assets for testing""" return { "assets": [ { "id": "asset_123", "filename": "IMG_20240101_120000.jpg", "created_at": "2024-01-01T12:00:00Z", "tags": ["family", "vacation"], "faces": ["person_1", "person_2"] } ] } @pytest.fixture(autouse=True) def mock_redis(): """Mock Redis client for all tests""" with patch('services.redis_client.redis_client') as mock_redis: mock_redis.ping.return_value = True mock_redis.set.return_value = True mock_redis.get.return_value = None yield mock_redis