34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
TEST_NAME = "students:create student"
|
|
|
|
|
|
def run(context) -> None:
|
|
status, _, _ = context.send_request("POST", "/api/students", body={})
|
|
context.expect(status == 401, f"expected 401, got {status}")
|
|
payload = {
|
|
context.K_FIRST_NAME: "Charlie",
|
|
context.K_LAST_NAME: "Stone",
|
|
context.K_MIDDLE_NAME: "Lee",
|
|
context.K_PASSWORD: "Student42",
|
|
context.K_CONFIRM_PASSWORD: "Student42",
|
|
context.K_SNILS: "00011122233",
|
|
context.K_PASSPORT: "AB1234567",
|
|
}
|
|
status, body, _ = context.send_request(
|
|
"POST",
|
|
"/api/students",
|
|
body=payload,
|
|
headers=context.make_auth(
|
|
context.teacher_username,
|
|
context.teacher_password,
|
|
),
|
|
)
|
|
context.expect(status == 201, f"expected 201, got {status}, body={body!r}")
|
|
context.student_one_id = context.query_single_value(
|
|
"SELECT id FROM students WHERE snils = ?",
|
|
(payload[context.K_SNILS],),
|
|
)
|
|
context.student_one_username = (
|
|
f"{payload[context.K_FIRST_NAME]}.{payload[context.K_LAST_NAME]}"
|
|
)
|
|
context.student_one_password = payload[context.K_PASSWORD]
|