Some checks failed
Docker Build and Push / build-and-push (push) Failing after 36s
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 1m11s
Integration Tests / integration-tests (push) Failing after 29s
LabFusion CI/CD Pipeline / api-docs (push) Successful in 1m42s
Integration Tests / performance-tests (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.1) (push) Failing after 11s
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 19s
LabFusion CI/CD Pipeline / frontend (push) Failing after 1m50s
LabFusion CI/CD Pipeline / integration-tests (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 20s
Service Adapters (Python FastAPI) / test (3.9) (push) Failing after 21s
Service Adapters (Python FastAPI) / build (push) Has been skipped
LabFusion CI/CD Pipeline / service-adapters (push) Failing after 20s
### Summary of Changes - Introduced a step to create a `tests/reports` directory in both CI workflows for Service Adapters and the main CI configuration. - This ensures that test reports have a designated location for output, improving organization and accessibility. ### Expected Results - Enhanced structure for test report generation, facilitating easier access to test results and improving overall CI workflow clarity.
107 lines
2.6 KiB
Python
107 lines
2.6 KiB
Python
"""
|
|
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
|