fix: Clean up and standardize test code formatting
Some checks failed
LabFusion CI/CD Pipeline / service-adapters (push) Failing after 20s
Docker Build and Push / build-and-push (push) Failing after 37s
Integration Tests / integration-tests (push) Failing after 32s
Integration Tests / performance-tests (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.1) (push) Failing after 15s
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 1m18s
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 22s
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 23s
Service Adapters (Python FastAPI) / test (3.9) (push) Failing after 21s
LabFusion CI/CD Pipeline / frontend (push) Failing after 2m0s
Service Adapters (Python FastAPI) / build (push) Has been skipped
LabFusion CI/CD Pipeline / api-docs (push) Successful in 1m53s
LabFusion CI/CD Pipeline / integration-tests (push) Has been skipped

### Summary of Changes
- Removed unnecessary blank lines and standardized import statements across test files.
- Ensured consistent use of quotes in patch decorators and improved formatting of test data structures.
- Enhanced readability and maintainability of test code by applying clean code principles.

### Expected Results
- Improved clarity and consistency in test code, facilitating easier understanding and future modifications.
This commit is contained in:
GSRN
2025-09-15 21:12:15 +02:00
parent 64d4e405c5
commit 8c37bff103
6 changed files with 82 additions and 114 deletions

View File

@@ -1,9 +1,11 @@
"""
Pytest configuration and fixtures for service adapters tests
"""
from unittest.mock import patch
import pytest
from fastapi.testclient import TestClient
from unittest.mock import patch
from main import app
@@ -21,17 +23,14 @@ def mock_services_config():
"home_assistant": {
"enabled": True,
"url": "http://homeassistant.local:8123",
"token": "test_token"
},
"frigate": {
"enabled": True,
"url": "http://frigate.local:5000"
"token": "test_token",
},
"frigate": {"enabled": True, "url": "http://frigate.local:5000"},
"immich": {
"enabled": False,
"url": "http://immich.local:2283",
"api_key": "test_key"
}
"api_key": "test_key",
},
}
@@ -42,18 +41,13 @@ def sample_ha_entities():
"sensor.temperature": {
"entity_id": "sensor.temperature",
"state": "22.5",
"attributes": {
"unit_of_measurement": "°C",
"friendly_name": "Temperature"
}
"attributes": {"unit_of_measurement": "°C", "friendly_name": "Temperature"},
},
"light.living_room": {
"entity_id": "light.living_room",
"state": "on",
"attributes": {
"friendly_name": "Living Room Light"
}
}
"attributes": {"friendly_name": "Living Room Light"},
},
}
@@ -67,15 +61,15 @@ def sample_frigate_events():
"timestamp": "2024-01-01T12:00:00Z",
"camera": "front_door",
"label": "person",
"confidence": 0.95
"confidence": 0.95,
},
{
"id": "event_456",
"timestamp": "2024-01-01T12:05:00Z",
"camera": "back_yard",
"label": "car",
"confidence": 0.87
}
"confidence": 0.87,
},
]
}
@@ -90,7 +84,7 @@ def sample_immich_assets():
"filename": "IMG_20240101_120000.jpg",
"created_at": "2024-01-01T12:00:00Z",
"tags": ["family", "vacation"],
"faces": ["person_1", "person_2"]
"faces": ["person_1", "person_2"],
}
]
}
@@ -99,7 +93,7 @@ def sample_immich_assets():
@pytest.fixture(autouse=True)
def mock_redis():
"""Mock Redis client for all tests"""
with patch('services.redis_client.redis_client') as mock_redis:
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