32 lines
916 B
Python
32 lines
916 B
Python
import json
|
|
|
|
TEST_NAME = "teachers:create class"
|
|
|
|
|
|
def run(context) -> None:
|
|
payload = {context.K_CLASS_NUMBER: 5, context.K_CLASS_LETTER: "A"}
|
|
status, body, _ = context.send_request(
|
|
"POST",
|
|
"/api/classes",
|
|
body=payload,
|
|
headers=context.make_auth(
|
|
context.teacher_username,
|
|
context.teacher_password,
|
|
),
|
|
)
|
|
context.expect(status == 201, f"expected 201, got {status}, body={body!r}")
|
|
data = json.loads(body)
|
|
context.class_id = int(data[context.K_IDENTIFIER])
|
|
context.expect(
|
|
data[context.K_CLASS_NUMBER] == payload[context.K_CLASS_NUMBER],
|
|
"class number mismatch",
|
|
)
|
|
context.expect(
|
|
data[context.K_CLASS_LETTER] == payload[context.K_CLASS_LETTER],
|
|
"class letter mismatch",
|
|
)
|
|
context.expect(
|
|
int(data[context.K_CREATOR]) > 0,
|
|
"creator id must be positive",
|
|
)
|