from models import Medaille

def test_postMedaille(client):
    medaille = Medaille(
        id=1,
        type="Argent",
        sport="Escrime",
        categorie="Fleuret",
        pays="Italie"
    )

    response = client.post("/", json=medaille.model_dump())
    assert response.status_code == 200
    medaille.id = response.json["id"]
    response = client.get(f"/{medaille.id}")

    assert response.json == medaille.model_dump()

def test_postMedaille_erreur(client):
    medaille = Medaille(
        id=1,
        type="NexistePas",
        sport="Escrime",
        categorie="Fleuret",
        pays="Italie"
    )

    response = client.post("/", json=medaille.model_dump())
    assert response.status_code == 400
    assert response.json == {'message': 'Données invalides'}
