32 lines
834 B
Python
32 lines
834 B
Python
import json
|
|
|
|
TEST_NAME = "students:list"
|
|
|
|
|
|
def run(context) -> None:
|
|
status, _, _ = context.send_request("GET", "/api/students")
|
|
context.expect(status == 401, f"expected 401, got {status}")
|
|
|
|
status, body, _ = context.send_request(
|
|
"GET",
|
|
"/api/students",
|
|
headers=context.make_auth(
|
|
context.teacher_username,
|
|
context.teacher_password,
|
|
),
|
|
)
|
|
context.expect(status == 200, f"expected 200, got {status}")
|
|
|
|
data = json.loads(body)
|
|
students = data.get("ученики", [])
|
|
ids = {int(item[context.K_IDENTIFIER]) for item in students}
|
|
|
|
context.expect(
|
|
context.student_one_id in ids,
|
|
"first student missing from list",
|
|
)
|
|
context.expect(
|
|
context.student_two_id in ids,
|
|
"second student missing from list",
|
|
)
|