feat: org router endpoint cleanup
`/id/` removed from GET Trailing `/` removed from POST and DELETE
This commit is contained in:
parent
806bbfcbfc
commit
81a4cc6cca
3 changed files with 8 additions and 8 deletions
|
|
@ -25,7 +25,7 @@ def get_org_model(db: Session, request: Request, org_id: int):
|
||||||
|
|
||||||
root = "/api/v1"
|
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}"
|
current_request = f"{request.method}{request.url.path}"
|
||||||
if current_request not in pre_approval_endpoints and org_model.status != OrgStatus.APPROVED:
|
if current_request not in pre_approval_endpoints and org_model.status != OrgStatus.APPROVED:
|
||||||
raise AwaitingApprovalException(org_id)
|
raise AwaitingApprovalException(org_id)
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ router = APIRouter(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/id",
|
@router.get("",
|
||||||
summary="Get org details by ID.",
|
summary="Get org details by ID.",
|
||||||
response_model=OrgGetOrgResponse,
|
response_model=OrgGetOrgResponse,
|
||||||
status_code=status.HTTP_200_OK,
|
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
|
return response
|
||||||
|
|
||||||
|
|
||||||
@router.post("/",
|
@router.post("",
|
||||||
summary="Create new organisation.",
|
summary="Create new organisation.",
|
||||||
status_code=status.HTTP_201_CREATED,
|
status_code=status.HTTP_201_CREATED,
|
||||||
response_model=OrgPostOrgResponse,
|
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
|
return response
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/",
|
@router.delete("",
|
||||||
summary="Delete organisation from the hub.",
|
summary="Delete organisation from the hub.",
|
||||||
status_code=status.HTTP_204_NO_CONTENT,
|
status_code=status.HTTP_204_NO_CONTENT,
|
||||||
responses={
|
responses={
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ from .conftest import client
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_get_org_success(client: AsyncClient):
|
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()
|
data = resp.json()
|
||||||
|
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
|
|
@ -33,14 +33,14 @@ async def test_get_org_success(client: AsyncClient):
|
||||||
)
|
)
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_get_org_failure(client: AsyncClient, query: str, expected_status: int):
|
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
|
assert resp.status_code == expected_status
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_post_org_success(client: AsyncClient):
|
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()
|
data = resp.json()
|
||||||
|
|
||||||
assert resp.status_code == 201
|
assert resp.status_code == 201
|
||||||
|
|
@ -58,7 +58,7 @@ async def test_post_org_success(client: AsyncClient):
|
||||||
)
|
)
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_post_org_failure(client: AsyncClient, body: dict[str, str], expected_status: int):
|
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
|
assert resp.status_code == expected_status
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue