cyntaria/UniPal-Backend

[PATCH] A Timetable

arafaysaleem opened this issue · 0 comments

Summary

As a student, I should be able to update details of a timetable, so that I can make the necessary changes.

Acceptance Criteria

GIVEN a student is editing a timetable in the app
WHEN the app hits the /timetables/:id endpoint with a valid PATCH request, containing:-
The path parameter:

  • :id, the unique id of the entity of which the details are edited.

And any of the following body parameters:

  • is_active tinyint(1)

THEN the app should receive a status 200
AND in the response, the following information should be returned:

  • header message indicating update operation success
  • rows matched
  • rows changed

Sample Request/Sample Response

headers: {
    error: 0,
    message: "The specified item was updated successfully"
}
body: {
    rows_matched: 1,
    rows_changed: 1,
    info: "..."
}

Resources

  • Development URL: {Here goes a URL to the feature on development API}
  • Production URL: {Here goes a URL to the feature on production API}

Dev Notes

{Some complementary notes if necessary}

Testing Notes

Scenario 1: PATCH request is successful (Owner)

  1. Update a timetable with a PATCH request to /timetables/:id endpoint with student_erp == erp in student account token and ensure a 200 status code is returned.
  2. A subsequent GET request to /timetables/:id endpoint should return a status code 200
  3. And the post details with the updated information i.e. matching the initially sent body.
  4. Resubmit a PATCH request to /timetables/:id endpoint to reverse the change and ensure status code 200 is returned.

Scenario 2: PATCH request is unsuccessful due to unknown timetable_id

  1. Update a timetable with a PATCH request to /timetables/:id endpoint containing a non-existent timetable_id.
  2. Ensure a 404 status code is returned.
  3. And the response headers' code parameter should contain "NotFoundException".

Scenario 3: PATCH request is incorrect

  1. Send a PATCH request to /timetables/:id endpoint with an incorrect key name in the body
  2. Ensure a 422 status code is returned
  3. And the response headers' code parameter should contain "InvalidPropertiesException".
  4. And the response headers' data parameter should contain the name of the invalid parameter.

Scenario 4: PATCH request is forbidden (Unowned Student ERP)

  1. Send a PATCH request to /timetables/:id endpoint with student_erp != erp in student account token.
  2. Ensure the response returns a 403 forbidden status code.
  3. And the response headers' code parameter should contain "ForbiddenException"

Scenario 5: PATCH request is unauthorized

  1. Send a PATCH request to /timetables/:id endpoint without an authorization token
  2. Ensure a 401 unauthorized status code is returned.
  3. And the response headers' code parameter should contain "TokenMissingException"