diff --git a/src/user/router.py b/src/user/router.py index f5ec0a7..0a37d6f 100644 --- a/src/user/router.py +++ b/src/user/router.py @@ -134,7 +134,7 @@ async def get_user_orgs(user_model: user_model_claims_dependency): "root_user_email": org.root_user_email, "billing_contact": { "id": org.billing_contact_id, - "email": org.owner_contact_rel.email, + "email": org.billing_contact_rel.email, }, "owner_contact": { "id": org.owner_contact_id, diff --git a/test/test_user.py b/test/test_user.py index 31fd2bb..c86914d 100644 --- a/test/test_user.py +++ b/test/test_user.py @@ -111,3 +111,35 @@ async def test_post_user_invitation_accept_status_checks( if resp.status_code == 401: assert resp.json()["detail"] == "Invalid JWS" + + +@pytest.mark.anyio +async def test_get_self_orgs_success(default_client: AsyncClient): + resp = await default_client.get("/user/self/orgs") + assert resp.status_code == 200 + + data = resp.json() + + assert "organisations" in data + assert isinstance(data["organisations"], list) + assert len(data["organisations"]) > 0 + + org = data["organisations"][0] + assert org["organisation_id"] == 1 + assert org["name"] == "Test Org" + assert org["status"] == "approved" + assert org["root_user_email"] == "admin@test.com" + assert "intake_questionnaire" in org + assert isinstance(org["intake_questionnaire"], dict) + + assert isinstance(org["billing_contact"], dict) + assert org["billing_contact"]["email"] == "billing@test.org" + assert org["billing_contact"]["id"] == 1 + + assert isinstance(org["owner_contact"], dict) + assert org["owner_contact"]["email"] == "owner@test.org" + assert org["owner_contact"]["id"] == 2 + + assert isinstance(org["security_contact"], dict) + assert org["security_contact"]["email"] == "security@test.org" + assert org["security_contact"]["id"] == 3