"""Small Flask route tests that do not call external translation services."""

from app import app


def test_health():
    client = app.test_client()
    response = client.get("/health")
    assert response.status_code == 200
    assert response.get_json() == {"status": "ok"}


def test_translate_requires_json():
    client = app.test_client()
    response = client.post("/translate", data="hello")
    assert response.status_code == 415


def test_translate_requires_text_and_target():
    client = app.test_client()

    response = client.post("/translate", json={"target": "en"})
    assert response.status_code == 400
    assert response.get_json()["error"] == "invalid_text"

    response = client.post("/translate", json={"text": "Bonjour"})
    assert response.status_code == 400
    assert response.get_json()["error"] == "invalid_target"
