init here
This commit is contained in:
48
autotest/cases/case_16_students_get.py
Normal file
48
autotest/cases/case_16_students_get.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import json
|
||||
|
||||
TEST_NAME = "students:get one"
|
||||
|
||||
|
||||
def run(context) -> None:
|
||||
path = f"/api/students/{context.student_one_id}"
|
||||
status, _, _ = context.send_request("GET", path)
|
||||
context.expect(status == 401, f"expected 401, got {status}")
|
||||
|
||||
status, body, _ = context.send_request(
|
||||
"GET",
|
||||
path,
|
||||
headers=context.make_auth(
|
||||
context.teacher_username,
|
||||
context.teacher_password,
|
||||
),
|
||||
)
|
||||
context.expect(status == 200, f"expected 200, got {status}")
|
||||
|
||||
data = json.loads(body)
|
||||
context.expect(
|
||||
int(data[context.K_IDENTIFIER]) == context.student_one_id,
|
||||
"unexpected student id",
|
||||
)
|
||||
context.expect(
|
||||
data.get(context.K_FIRST_NAME),
|
||||
"missing student first name",
|
||||
)
|
||||
context.expect(
|
||||
data.get(context.K_LAST_NAME),
|
||||
"missing student last name",
|
||||
)
|
||||
context.expect(
|
||||
data.get(context.K_USERNAME),
|
||||
"missing student username",
|
||||
)
|
||||
|
||||
missing_path = f"/api/students/{context.student_two_id + 999}"
|
||||
status, _, _ = context.send_request(
|
||||
"GET",
|
||||
missing_path,
|
||||
headers=context.make_auth(
|
||||
context.teacher_username,
|
||||
context.teacher_password,
|
||||
),
|
||||
)
|
||||
context.expect(status == 404, f"expected 404, got {status}")
|
||||
Reference in New Issue
Block a user