feat(phase-20): navigation, error handling, integration tests, and V2 docs (T-132 to T-135)
This commit is contained in:
@@ -286,13 +286,17 @@ def update_test(
|
||||
if current_user.role != "admin" and test.created_by != current_user.id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Not enough permissions",
|
||||
detail={"message": "Only the test creator or an admin can update this test", "code": "FORBIDDEN"},
|
||||
)
|
||||
|
||||
if test.state not in (TestState.draft, TestState.rejected):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Cannot update a test in '{test.state.value}' state (must be draft or rejected)",
|
||||
detail={
|
||||
"message": f"Cannot update a test in '{test.state.value}' state (must be draft or rejected)",
|
||||
"code": "INVALID_STATE",
|
||||
"current_state": test.state.value,
|
||||
},
|
||||
)
|
||||
|
||||
update_data = payload.model_dump(exclude_unset=True)
|
||||
@@ -332,7 +336,11 @@ def update_test_red(
|
||||
if test.state not in (TestState.draft, TestState.red_executing):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Cannot update red fields in '{test.state.value}' state (must be draft or red_executing)",
|
||||
detail={
|
||||
"message": f"Cannot update red fields in '{test.state.value}' state (must be draft or red_executing)",
|
||||
"code": "INVALID_STATE",
|
||||
"current_state": test.state.value,
|
||||
},
|
||||
)
|
||||
|
||||
update_data = payload.model_dump(exclude_unset=True)
|
||||
@@ -372,7 +380,11 @@ def update_test_blue(
|
||||
if test.state != TestState.blue_evaluating:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Cannot update blue fields in '{test.state.value}' state (must be blue_evaluating)",
|
||||
detail={
|
||||
"message": f"Cannot update blue fields in '{test.state.value}' state (must be blue_evaluating)",
|
||||
"code": "INVALID_STATE",
|
||||
"current_state": test.state.value,
|
||||
},
|
||||
)
|
||||
|
||||
update_data = payload.model_dump(exclude_unset=True)
|
||||
|
||||
Reference in New Issue
Block a user