1
0
Fork 0
forked from sr2/cloud-api

feat: org router endpoint cleanup

`/id/` removed from GET
Trailing `/` removed from POST and DELETE
This commit is contained in:
Chris Milne 2026-06-02 16:23:29 +01:00
parent 806bbfcbfc
commit 81a4cc6cca
3 changed files with 8 additions and 8 deletions

View file

@ -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)

View file

@ -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={

View file

@ -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