Files
maziggy b99536cc33 Remove unused imports, variables, and fix minor CodeQL findings
- Remove 28 unused imports across 22 test files
- Prefix 4 unused local variables with _ in app code
  (archives, bambu_mqtt, main) and remove 1 dead store
- Consolidate import/import-from in test_plate_detection.py
- Fix unreachable statement in test_archive_service.py
- Simplify redundant comparison in timelapse_processor.py

Resolves ~50 CodeQL py/unused-import, py/unused-local-variable,
py/import-and-import-from, py/unreachable-statement, and
py/redundant-comparison findings.
2026-02-06 12:19:17 +01:00

48 lines
1.8 KiB
Python

"""Integration tests for Updates API endpoints."""
from unittest.mock import AsyncMock, patch
import pytest
from httpx import AsyncClient
class TestUpdatesAPI:
@pytest.mark.asyncio
async def test_get_version(self, async_client: AsyncClient):
response = await async_client.get("/api/v1/updates/version")
assert response.status_code == 200
@pytest.mark.asyncio
async def test_apply_update_docker_rejection(self, async_client: AsyncClient):
with patch("backend.app.api.routes.updates._is_docker_environment", return_value=True):
response = await async_client.post("/api/v1/updates/apply")
result = response.json()
assert result["success"] is False
assert result["is_docker"] is True
@pytest.mark.asyncio
async def test_apply_update_non_docker(self, async_client: AsyncClient):
"""Test non-Docker path - mock _perform_update to prevent side effects."""
with (
patch("backend.app.api.routes.updates._is_docker_environment", return_value=False),
patch("backend.app.api.routes.updates._perform_update", new_callable=AsyncMock),
):
response = await async_client.post("/api/v1/updates/apply")
assert response.json()["success"] is True
def test_is_docker_with_dockerenv(self):
from backend.app.api.routes.updates import _is_docker_environment
with patch("os.path.exists", return_value=True):
assert _is_docker_environment() is True
def test_parse_version(self):
from backend.app.api.routes.updates import parse_version
assert parse_version("0.1.5")[:3] == (0, 1, 5)
def test_is_newer_version(self):
from backend.app.api.routes.updates import is_newer_version
assert is_newer_version("0.1.5", "0.1.5b7") is True