[POST] A New Class
arafaysaleem opened this issue · 0 comments
arafaysaleem commented
Summary
As an admin
, I should be able to create classes, so that students can choose them for timetables.
Acceptance Criteria
GIVEN a student
is creating a class in the app
WHEN the app hits the /classes
endpoint with a valid class request, containing:
- an array of classes
[
{
`class_erp` varchar(5) NOT NULL,
`semester` varchar(45) NOT NULL,
`classroom_id` int(10) unsigned NOT NULL,
`term_id` int(10) unsigned NOT NULL,
`subject_code` varchar(6) NOT NULL,
`teacher_id` int(10) unsigned NOT NULL,
`parent_class_erp` varchar(5) DEFAULT NULL,
`timeslot_1` int(10) unsigned NOT NULL,
`timeslot_2` int(10) unsigned NOT NULL,
`day_1` enum('monday','tuesday','wednesday','thursday','friday','saturday','sunday') NOT NULL,
`day_2` enum('monday','tuesday','wednesday','thursday','friday','saturday','sunday') NOT NULL
}
]
THEN the app should receive a status 201
AND in the response, the following information should be returned:
- headers
- affected_rows
Sample Request/Sample Response
headers: {
error: 0,
message: "..."
}
body: {
"affected_rows": 1
}
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: POST request is successful
- Create a new class entries with a POST request to
/classes
endpoint withadmin
token and ensure a201
status code is returned. - Make a subsequent GET request to
/classes/:class_erp
endpoint and ensure a200
status code is returned. - Ensure the response contains a class with the correct information i.e. matching the initially sent body.
- Clean up the database by sending a DELETE request to
/classes/:class_erp
endpoint and ensure a200
status code is returned.
Scenario 2: POST request is unsuccessful due to unknown term_id
- Make a POST request to
/classes
endpoint using anadmin
token containing body parameter:
term_id
, a non-existent id
- Ensure a
512
status code is returned. - And the response headers'
code
parameter should contain "ForeignKeyViolationException" - And the response headers'
message
parameter should contain "term_id"
Scenario 3: POST request is unsuccessful due to unknown subject_code
- Make a POST request to
/classes
endpoint using anadmin
token containing body parameter:
subject_code
, a non-existent id
- Ensure a
512
status code is returned. - And the response headers'
code
parameter should contain "ForeignKeyViolationException" - And the response headers'
message
parameter should contain "subject_code"
Scenario 4: POST request is unsuccessful due to unknown teacher_id
- Make a POST request to
/classes
endpoint using anadmin
token containing body parameter:
teacher_id
, a non-existent id
- Ensure a
512
status code is returned. - And the response headers'
code
parameter should contain "ForeignKeyViolationException" - And the response headers'
message
parameter should contain "teacher_id"
Scenario 5: POST request is unsuccessful due to unknown classroom_id
- Make a POST request to
/classes
endpoint using anadmin
token containing body parameter:
classroom_id
, a non-existent id
- Ensure a
512
status code is returned. - And the response headers'
code
parameter should contain "ForeignKeyViolationException" - And the response headers'
message
parameter should contain "classroom_id"
Scenario 6: POST request is unsuccessful due to unknown timeslot_id
- Make a POST request to
/classes
endpoint using anadmin
token containing body parameter:
timeslot_1
, a non-existent id
- Ensure a
512
status code is returned. - And the response headers'
code
parameter should contain "ForeignKeyViolationException" - And the response headers'
message
parameter should contain "timeslot_id"
Scenario 7: POST request is unsuccessful due to unknown parent_class_erp
- Make a POST request to
/classes
endpoint using anadmin
token containing body parameter:
parent_class_erp
, a non-existent id
- Ensure a
512
status code is returned. - And the response headers'
code
parameter should contain "ForeignKeyViolationException" - And the response headers'
message
parameter should contain "parent_class_erp"
Scenario 8: POST request is incorrect
- Send a POST request to
/classes
endpoint with an incorrect key name in the body - Ensure a
422
status code is returned - And the response headers'
code
parameter should contain "InvalidPropertiesException" - And the response headers'
data
parameter should contain the name of the invalid parameter
Scenario 9: POST request is forbidden
- Send a POST request to
/classes
endpoint using astudent
account token. - Ensure the response returns a
403
forbidden status code. - And the response headers'
code
parameter should contain "ForbiddenException"
Scenario 10: POST request is unauthorized
- Send a POST request to
/classes
endpoint without an authorization token - Ensure a
401
unauthorized status code is returned. - And the response headers'
code
parameter should contain "TokenMissingException"