feat(translation): Post translation columns + settings + migration (#143 step 1)
Post gains post_title_translated / description_translated / translated_source_lang / translation_engine_version / translated_at — filled by the translate sweep so viewing is instant. ImportSettings gains translation_enabled (OFF by default), interpreter_base_url (EMPTY — no default host; the operator points it at their own Interpreter proxy behind a reverse proxy) and translation_target_lang (en), exposed + validated via /settings/import. Migration 0083. Settings defaults + patch + validation test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CDgx8bQS5YrGRK76v8HUnM
This commit is contained in:
@@ -28,6 +28,31 @@ async def test_patch_import_settings(client):
|
||||
assert body["transparency_threshold"] == 0.7
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_translation_settings_defaults_and_patch(client):
|
||||
# #143: translation is OFF by default with NO default host — the operator
|
||||
# points it at their own Interpreter proxy and enables it.
|
||||
body = await (await client.get("/api/settings/import")).get_json()
|
||||
assert body["translation_enabled"] is False
|
||||
assert body["interpreter_base_url"] == ""
|
||||
assert body["translation_target_lang"] == "en"
|
||||
|
||||
ok = await client.patch("/api/settings/import", json={
|
||||
"translation_enabled": True,
|
||||
"interpreter_base_url": "http://interpreter.lan",
|
||||
})
|
||||
assert ok.status_code == 200
|
||||
out = await ok.get_json()
|
||||
assert out["translation_enabled"] is True
|
||||
assert out["interpreter_base_url"] == "http://interpreter.lan"
|
||||
|
||||
# Type validation.
|
||||
assert (await client.patch(
|
||||
"/api/settings/import", json={"translation_enabled": "yes"})).status_code == 400
|
||||
assert (await client.patch(
|
||||
"/api/settings/import", json={"interpreter_base_url": 123})).status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_patch_rejects_non_object(client):
|
||||
resp = await client.patch("/api/settings/import", json=[1, 2, 3])
|
||||
|
||||
Reference in New Issue
Block a user