fix(translate): French error messages and update mock users for quota checks
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m52s

This commit is contained in:
2026-06-14 19:20:44 +02:00
parent adc3583358
commit b9446f166d
5 changed files with 61 additions and 25 deletions

View File

@@ -5,13 +5,28 @@ from unittest.mock import patch, AsyncMock, MagicMock
from main import app
from routes.translate_routes import get_authenticated_user
client = TestClient(app)
@pytest.fixture()
def client(monkeypatch):
"""TestClient with rate limiting and quota reservation bypassed for metadata tests."""
from middleware.rate_limiting import RateLimitMiddleware
async def _dispatch(self, request, call_next):
return await call_next(request)
monkeypatch.setattr(RateLimitMiddleware, "dispatch", _dispatch)
monkeypatch.setattr("routes.translate_routes.reserve_translation_quota", lambda user_id: True)
from main import app
return TestClient(app)
class MockUser:
def __init__(self, user_id="user_123"):
self.id = user_id
self.plan = "free"
self.docs_translated_this_month = 0
self.pages_translated_this_month = 0
self.extra_credits = 0
async def mock_auth():
@@ -19,7 +34,7 @@ async def mock_auth():
@pytest.mark.asyncio
async def test_translate_endpoint_triggers_tracking():
async def test_translate_endpoint_triggers_tracking(client):
app.dependency_overrides[get_authenticated_user] = mock_auth
with patch(
@@ -70,7 +85,7 @@ async def test_translate_endpoint_triggers_tracking():
@pytest.mark.asyncio
async def test_translate_endpoint_handles_hash_failure():
async def test_translate_endpoint_handles_hash_failure(client):
app.dependency_overrides[get_authenticated_user] = mock_auth
with patch("routes.translate_routes.file_validator.validate_async") as mock_val: