Files
romm/backend/tests/endpoints/test_platform.py
Georges-Antoine Assi 0158097389 fix(platform): accept embedded custom_name body on platform update
Removing the aspect_ratio body field left update_platform with a single
scalar Body() param. FastAPI stops embedding a lone scalar body, so the
endpoint began expecting a bare JSON string while the frontend keeps
sending {"custom_name": "..."}, producing a 422 when editing a
platform's display name in v2.

Restore the embedded-key contract with Body(embed=True), matching the
frontend payload and every sibling update endpoint. Regenerate the
frontend types (restores the Body_update_platform model) and add an
endpoint regression test.

AI assistance: written with Claude Code (Opus 4.8).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 09:21:10 -04:00

27 lines
945 B
Python

from fastapi import status
def test_get_platforms(client, access_token, platform):
response = client.get("/api/platforms")
assert response.status_code == status.HTTP_403_FORBIDDEN
response = client.get(
"/api/platforms", headers={"Authorization": f"Bearer {access_token}"}
)
assert response.status_code == status.HTTP_200_OK
platforms = response.json()
assert len(platforms) == 1
def test_update_platform_custom_name(client, access_token, platform):
# The body is an embedded key, not a bare scalar; sending {"custom_name": ...}
# must be accepted (regression against the single-body-param 422).
response = client.put(
f"/api/platforms/{platform.id}",
headers={"Authorization": f"Bearer {access_token}"},
json={"custom_name": "My Custom Name"},
)
assert response.status_code == status.HTTP_200_OK
assert response.json()["custom_name"] == "My Custom Name"