From 81a4cc6ccac6d6376d7223ad5accf59406138954 Mon Sep 17 00:00:00 2001 From: luxferre Date: Tue, 2 Jun 2026 16:23:29 +0100 Subject: [PATCH] feat: org router endpoint cleanup `/id/` removed from GET Trailing `/` removed from POST and DELETE --- src/organisation/dependencies.py | 2 +- src/organisation/router.py | 6 +++--- test/test_organisation.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/organisation/dependencies.py b/src/organisation/dependencies.py index ec8805c..728b8d0 100644 --- a/src/organisation/dependencies.py +++ b/src/organisation/dependencies.py @@ -25,7 +25,7 @@ def get_org_model(db: Session, request: Request, org_id: int): root = "/api/v1" - pre_approval_endpoints = [f"PATCH{root}/org/status", f"PATCH{root}/org/questionnaire", f"GET{root}/org/id", f"GET{root}/org/contact", f"PATCH{root}/org/contact"] + pre_approval_endpoints = [f"PATCH{root}/org/status", f"PATCH{root}/org/questionnaire", f"GET{root}/org", f"GET{root}/org/contact", f"PATCH{root}/org/contact"] current_request = f"{request.method}{request.url.path}" if current_request not in pre_approval_endpoints and org_model.status != OrgStatus.APPROVED: raise AwaitingApprovalException(org_id) diff --git a/src/organisation/router.py b/src/organisation/router.py index 65d2d71..ec50fde 100644 --- a/src/organisation/router.py +++ b/src/organisation/router.py @@ -47,7 +47,7 @@ router = APIRouter( ) -@router.get("/id", +@router.get("", summary="Get org details by ID.", response_model=OrgGetOrgResponse, status_code=status.HTTP_200_OK, @@ -73,7 +73,7 @@ async def get_org_by_id(org_model: org_model_root_claim_query_dependency): return response -@router.post("/", +@router.post("", summary="Create new organisation.", status_code=status.HTTP_201_CREATED, response_model=OrgPostOrgResponse, @@ -201,7 +201,7 @@ async def add_user_to_org(db: db_dependency, org_model: org_model_root_claim_bod return response -@router.delete("/", +@router.delete("", summary="Delete organisation from the hub.", status_code=status.HTTP_204_NO_CONTENT, responses={ diff --git a/test/test_organisation.py b/test/test_organisation.py index a629d04..906563d 100644 --- a/test/test_organisation.py +++ b/test/test_organisation.py @@ -11,7 +11,7 @@ from .conftest import client @pytest.mark.anyio async def test_get_org_success(client: AsyncClient): - resp = await client.get("/org/id?org_id=1") + resp = await client.get("/org?org_id=1") data = resp.json() assert resp.status_code == 200 @@ -33,14 +33,14 @@ async def test_get_org_success(client: AsyncClient): ) @pytest.mark.anyio async def test_get_org_failure(client: AsyncClient, query: str, expected_status: int): - resp = await client.get(f"/org/id?{query}") + resp = await client.get(f"/org?{query}") assert resp.status_code == expected_status @pytest.mark.anyio async def test_post_org_success(client: AsyncClient): - resp = await client.post("/org/", json={"name": "New Test Org"}) + resp = await client.post("/org", json={"name": "New Test Org"}) data = resp.json() assert resp.status_code == 201 @@ -58,7 +58,7 @@ async def test_post_org_success(client: AsyncClient): ) @pytest.mark.anyio async def test_post_org_failure(client: AsyncClient, body: dict[str, str], expected_status: int): - resp = await client.post("/org/", json=body) + resp = await client.post("/org", json=body) assert resp.status_code == expected_status