26 lines
975 B
Python
26 lines
975 B
Python
TEST_NAME = "users:create teacher"
|
|
|
|
|
|
def run(context) -> None:
|
|
payload = {
|
|
context.K_FIRST_NAME: context.teacher_first,
|
|
context.K_LAST_NAME: context.teacher_last,
|
|
context.K_MIDDLE_NAME: context.teacher_middle,
|
|
context.K_EDUCATION: context.teacher_education,
|
|
context.K_PASSWORD: context.teacher_password,
|
|
context.K_CONFIRM_PASSWORD: context.teacher_password,
|
|
}
|
|
status, body, _ = context.send_request("POST", "/api/users", body=payload)
|
|
context.expect(status == 201, f"expected 201, got {status}, body={body!r}")
|
|
user_id = context.query_single_value(
|
|
"SELECT id FROM users WHERE username = ?",
|
|
(context.teacher_username,),
|
|
)
|
|
context.teacher_user_id = user_id
|
|
teacher_id = context.query_single_value(
|
|
"SELECT id FROM teachers WHERE user_id = ?",
|
|
(user_id,),
|
|
)
|
|
context.expect(teacher_id > 0, "teacher id must be positive")
|
|
context.teacher_id = teacher_id
|