log: remove dead _resolve_log_content helper from pages.py
The HTMX log endpoints in api.py do their own localization via _localized_content; the pages.py helper was added during the initial localization wiring but was bypassed once HTMX rendering landed. No call sites remain.
This commit is contained in:
parent
664757ea8a
commit
eedd32b885
2 changed files with 1 additions and 82 deletions
|
|
@ -327,66 +327,6 @@ def test_digest_pick_variant_uses_user_lang():
|
|||
assert ed._pick_variant(table, tone="UNKNOWN", lang="en") == "intermediate en"
|
||||
|
||||
|
||||
async def test_log_endpoint_serves_italian_when_user_is_italian(tmp_path):
|
||||
"""When a user with lang='it' opens /log, the served content is the
|
||||
Italian translation, not the English original."""
|
||||
from app.db import utcnow
|
||||
from app.models import StrategicLog, StrategicLogTranslation, User
|
||||
|
||||
_, factory, setup = _build_session_factory(tmp_path)
|
||||
await setup()
|
||||
|
||||
async with factory() as session:
|
||||
session.add(User(id=10, email="it@x", tier="paid", lang="it"))
|
||||
slog = StrategicLog(
|
||||
generated_at=utcnow(), content="# Open\n\nDown 0.4%.",
|
||||
model="test-model",
|
||||
tone="INTERMEDIATE", analysis="NORMAL",
|
||||
)
|
||||
session.add(slog)
|
||||
await session.commit()
|
||||
session.add(StrategicLogTranslation(
|
||||
log_id=slog.id, lang="it",
|
||||
content_md="# Apertura\n\nIn calo 0,4%.",
|
||||
generated_at=utcnow(), llm_model="m", llm_cost_usd=0.0,
|
||||
))
|
||||
await session.commit()
|
||||
log_id = slog.id
|
||||
|
||||
# Test the resolver directly.
|
||||
from app.routers.pages import _resolve_log_content
|
||||
async with factory() as session:
|
||||
user = await session.get(User, 10)
|
||||
content = await _resolve_log_content(session, log_id, user.lang)
|
||||
assert "Apertura" in content
|
||||
assert "Open" not in content
|
||||
|
||||
|
||||
async def test_log_endpoint_falls_back_to_english_when_no_translation(tmp_path):
|
||||
"""User lang='it' but no IT translation exists → English fallback."""
|
||||
from app.db import utcnow
|
||||
from app.models import StrategicLog, User
|
||||
|
||||
_, factory, setup = _build_session_factory(tmp_path)
|
||||
await setup()
|
||||
|
||||
async with factory() as session:
|
||||
session.add(User(id=11, email="it2@x", tier="paid", lang="it"))
|
||||
slog = StrategicLog(
|
||||
generated_at=utcnow(), content="# Open\n\nDown 0.4%.",
|
||||
model="test-model",
|
||||
tone="INTERMEDIATE", analysis="NORMAL",
|
||||
)
|
||||
session.add(slog)
|
||||
await session.commit()
|
||||
log_id = slog.id
|
||||
|
||||
from app.routers.pages import _resolve_log_content
|
||||
async with factory() as session:
|
||||
user = await session.get(User, 11)
|
||||
content = await _resolve_log_content(session, log_id, user.lang)
|
||||
assert "Open" in content
|
||||
|
||||
|
||||
async def test_patch_language_accepts_active(tmp_path):
|
||||
"""PATCH /api/settings/language accepts 'en' and 'it' and persists."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue