fix: ruff lint + format fixes in tests, ESLint fixes in frontend

This commit is contained in:
2026-07-17 21:28:58 +02:00
parent 341d0c6f38
commit fbb1b39b57
56 changed files with 1399 additions and 721 deletions
+27 -13
View File
@@ -6,8 +6,6 @@ from decimal import Decimal
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
import pytest_asyncio
from sqlalchemy.ext.asyncio import AsyncSession
from app.models.vehicle import MobileDeListing, Vehicle
from app.services import mobilede_service
@@ -157,7 +155,9 @@ class TestPushListing:
db_session.add(vehicle)
await db_session.flush()
with patch("app.services.mobilede_service.httpx.AsyncClient") as mock_client_cls:
with patch(
"app.services.mobilede_service.httpx.AsyncClient"
) as mock_client_cls:
mock_response = MagicMock()
mock_response.status_code = 201
mock_response.json.return_value = {"id": "ad-123"}
@@ -184,7 +184,9 @@ class TestPushListing:
db_session.add(vehicle)
await db_session.flush()
with patch("app.services.mobilede_service.httpx.AsyncClient") as mock_client_cls:
with patch(
"app.services.mobilede_service.httpx.AsyncClient"
) as mock_client_cls:
mock_response = MagicMock()
mock_response.status_code = 400
mock_response.text = "Bad Request"
@@ -212,9 +214,13 @@ class TestPushListing:
db_session.add(vehicle)
await db_session.flush()
with patch("app.services.mobilede_service.httpx.AsyncClient") as mock_client_cls:
with patch(
"app.services.mobilede_service.httpx.AsyncClient"
) as mock_client_cls:
mock_client = AsyncMock()
mock_client.post = AsyncMock(side_effect=httpx.ConnectError("Connection refused"))
mock_client.post = AsyncMock(
side_effect=httpx.ConnectError("Connection refused")
)
mock_client.__aenter__ = AsyncMock(return_value=mock_client)
mock_client.__aexit__ = AsyncMock(return_value=None)
mock_client_cls.return_value = mock_client
@@ -243,7 +249,9 @@ class TestUpdateListing:
db_session.add(listing)
await db_session.flush()
with patch("app.services.mobilede_service.httpx.AsyncClient") as mock_client_cls:
with patch(
"app.services.mobilede_service.httpx.AsyncClient"
) as mock_client_cls:
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.raise_for_status = MagicMock()
@@ -296,7 +304,9 @@ class TestDeleteListing:
db_session.add(listing)
await db_session.flush()
with patch("app.services.mobilede_service.httpx.AsyncClient") as mock_client_cls:
with patch(
"app.services.mobilede_service.httpx.AsyncClient"
) as mock_client_cls:
mock_response = MagicMock()
mock_response.status_code = 204
mock_response.raise_for_status = MagicMock()
@@ -340,8 +350,6 @@ class TestGetListingStatus:
db_session.add(vehicle)
await db_session.flush()
from datetime import datetime, timezone, timedelta
listing1 = MobileDeListing(
vehicle_id=vehicle.id,
sync_status="fehler",
@@ -392,7 +400,9 @@ class TestRetryFailedListing:
db_session.add(listing)
await db_session.flush()
with patch("app.services.mobilede_service.httpx.AsyncClient") as mock_client_cls:
with patch(
"app.services.mobilede_service.httpx.AsyncClient"
) as mock_client_cls:
mock_response = MagicMock()
mock_response.status_code = 201
mock_response.json.return_value = {"id": "ad-789"}
@@ -403,7 +413,9 @@ class TestRetryFailedListing:
mock_client.__aexit__ = AsyncMock(return_value=None)
mock_client_cls.return_value = mock_client
result = await mobilede_service.retry_failed_listing(db_session, listing, vehicle)
result = await mobilede_service.retry_failed_listing(
db_session, listing, vehicle
)
assert result.sync_status == "synced"
assert result.ad_id == "ad-789"
@@ -423,7 +435,9 @@ class TestRetryFailedListing:
db_session.add(listing)
await db_session.flush()
result = await mobilede_service.retry_failed_listing(db_session, listing, vehicle)
result = await mobilede_service.retry_failed_listing(
db_session, listing, vehicle
)
assert result.sync_status == "fehler"
assert "Max retries" in result.error_log