Files
jardin/backend/tests/test_media_aliases.py
2026-02-22 22:18:32 +01:00

27 lines
760 B
Python

def test_create_media_normalizes_english_entity_type(client):
r = client.post(
"/api/media",
json={
"entity_type": "plant",
"entity_id": 12,
"url": "/uploads/test.webp",
},
)
assert r.status_code == 201
assert r.json()["entity_type"] == "plante"
def test_list_media_accepts_alias_entity_type_filter(client):
client.post(
"/api/media",
json={
"entity_type": "plante",
"entity_id": 99,
"url": "/uploads/test2.webp",
},
)
r = client.get("/api/media", params={"entity_type": "plant", "entity_id": 99})
assert r.status_code == 200
assert len(r.json()) == 1
assert r.json()[0]["entity_type"] == "plante"