Files
Salon/backend/apps/accounts/tests/test_locale.py
T
mohd d40bb10876 Updated PLANS.md, AGENTS.md, and arabic-localization.md to reflect the “foundations now, full translations later” approach and marked progress accordingly.
Implemented localization foundations across backend and frontend (locale settings/middleware, preferred language, i18n wiring, RTL support, minimal Arabic UI strings, Accept-Language).
Added targeted backend and frontend tests plus a risks note for pending full translation coverage.
2026-02-28 11:48:58 +03:00

30 lines
876 B
Python

import pytest
from django.urls import reverse
from apps.accounts.models import User
@pytest.mark.django_db
def test_accept_language_sets_content_language_header(client):
response = client.post(
reverse("otp_request"),
{"phone_number": "123", "channel": "sms"},
content_type="application/json",
HTTP_ACCEPT_LANGUAGE="en",
)
assert response.headers.get("Content-Language") == "en"
@pytest.mark.django_db
def test_user_preference_overrides_accept_language(client):
user = User.objects.create_user(
email="locale@example.com",
phone_number="+966512345678",
)
user.preferred_language = "en"
user.save(update_fields=["preferred_language"])
client.force_login(user)
response = client.get(reverse("me"), HTTP_ACCEPT_LANGUAGE="ar-sa")
assert response.headers.get("Content-Language") == "en"