def test_get_profile_empty(client): r = client.get("/profile") assert r.status_code == 200 assert r.json() is None def test_upsert_profile_create_and_get(client): create = client.patch( "/profile", json={"birth_date": "1990-01-15", "sex_at_birth": "male"} ) assert create.status_code == 200 body = create.json() assert body["birth_date"] == "1990-01-15" assert body["sex_at_birth"] == "male" fetch = client.get("/profile") assert fetch.status_code == 200 fetched = fetch.json() assert fetched is not None assert fetched["id"] == body["id"] def test_upsert_profile_updates_existing_row(client): first = client.patch( "/profile", json={"birth_date": "1992-06-10", "sex_at_birth": "female"} ) assert first.status_code == 200 first_id = first.json()["id"] second = client.patch("/profile", json={"sex_at_birth": "intersex"}) assert second.status_code == 200 second_body = second.json() assert second_body["id"] == first_id assert second_body["birth_date"] == "1992-06-10" assert second_body["sex_at_birth"] == "intersex"