.
This commit is contained in:
@@ -50,12 +50,39 @@ def test_exams(db, client):
|
|||||||
|
|
||||||
active_exams = client.get(reverse(f"{APP_NAME}:active_exams"))
|
active_exams = client.get(reverse(f"{APP_NAME}:active_exams"))
|
||||||
assert active_exams.status_code == 200
|
assert active_exams.status_code == 200
|
||||||
assert len(json.load(active_exams.content)) == 0
|
assert len(json.loads(active_exams.content)["exams"]) == 0
|
||||||
|
|
||||||
cid_user_1001 = CidUser.objects.get(cid=1001)
|
cid_user_1001 = CidUser.objects.get(cid=1001)
|
||||||
|
|
||||||
for cid_user in [cid_user_1001]
|
for cid_user in [cid_user_1001]:
|
||||||
active_exams_cid = client.get(reverse(f"{APP_NAME}:active_exams_cid", ))
|
# Test active exams sections works as intended
|
||||||
|
active_exams_cid = client.get(reverse(f"active_exams_cid", kwargs={"cid":cid_user.cid, "passcode":cid_user.passcode}))
|
||||||
|
|
||||||
|
assert active_exams_cid.status_code == 200
|
||||||
|
assert len(json.loads(active_exams_cid.content)["exams"]) == 1
|
||||||
|
|
||||||
|
active_exams_cid = client.get(reverse(f"active_exams_cid", kwargs={"cid":1001, "passcode":"EFGH"}))
|
||||||
|
|
||||||
|
assert active_exams_cid.status_code == 200
|
||||||
|
assert len(json.loads(active_exams_cid.content)["exams"]) == 1
|
||||||
|
|
||||||
|
no_active_exams_cid = client.get(reverse(f"active_exams_cid", kwargs={"cid":2001, "passcode":"EGFH"}))
|
||||||
|
|
||||||
|
assert no_active_exams_cid.status_code == 401
|
||||||
|
assert json.loads(no_active_exams_cid.content)["status"] == "invalid"
|
||||||
|
|
||||||
|
invalid_passcode = client.get(reverse(f"active_exams_cid", kwargs={"cid":1001, "passcode":"ABCD"}))
|
||||||
|
assert invalid_passcode.status_code == 401
|
||||||
|
assert json.loads(invalid_passcode.content)["status"] == "invalid"
|
||||||
|
|
||||||
|
exam_metadata = json.loads(active_exams_cid.content)["exams"][0]
|
||||||
|
|
||||||
|
assert exam_metadata["name"] == "Cid Exam"
|
||||||
|
assert exam_metadata["exam_active"] == True
|
||||||
|
assert exam_metadata["exam_mode"] == True
|
||||||
|
|
||||||
|
#exam_json = client.get(exam_metadata["url"])
|
||||||
|
#print(exam_json.status_code)
|
||||||
|
#print(exam_json.content)
|
||||||
|
|
||||||
|
|
||||||
print(active_exams_cid.status_code)
|
|
||||||
print(active_exams_cid.content)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user