Skip to content

Commit

Permalink
ADD regrading tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dolf321 committed May 22, 2023
1 parent 42c6dd2 commit d98b974
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/anubis/views/admin/regrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def admin_regrade_status(assignment: Assignment):
@regrade.route("/status/student/<string:netid>")
@require_admin()
@json_response
def admin_regrade_status(netid: str):
def admin_regrade_status_student(netid: str):
"""
Get the autograde status for astudent. The status
Get the autograde status for a student. The status
is some high level stats the proportion of submissions
within the assignments for that student that have been processed
Expand Down
30 changes: 28 additions & 2 deletions api/tests/test_regrade_admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from utils import Session, permission_test, with_context

import pytest, time
from anubis.models import Submission


@with_context
def get_student_submission_commit(assignment_ids):
for assignment_id in assignment_ids:
Expand All @@ -13,7 +13,6 @@ def get_student_submission_commit(assignment_ids):
if submission is not None:
return submission.commit, assignment_id


def test_regrade_admin():
superuser = Session("superuser")
assignments = superuser.get("/admin/assignments/list")["assignments"]
Expand All @@ -23,3 +22,30 @@ def test_regrade_admin():
permission_test(f"/admin/regrade/status/{assignment_id}")
permission_test(f"/admin/regrade/submission/{commit}")
permission_test(f"/admin/regrade/assignment/{assignment_id}")

@pytest.mark.timeout(40)
def test_regrade_admin_student():
superuser = Session("superuser")
# Get list of students
students = superuser.get("/admin/students/list")["students"]
assert len(students) > 0
student_netid = students[0]["netid"]

# Permission tests
permission_test(f"/admin/regrade/student/{student_netid}")
permission_test(f"/admin/regrade/status/student/{student_netid}")

# Test Submissions pipeline
resp = superuser.get(f"/admin/regrade/student/{student_netid}")
assert resp["status"] == "Regrade enqueued."

# get the status of the regrade for a student and make sure they get fully procesed
status = superuser.get(f"/admin/regrade/status/student/{student_netid}")

# make sure total is greater than 0 (meaning it has actually been enqueued)
assert status["total"] > 0

while (status["processed"] !=status["total"]):
time.sleep(5)
status = superuser.get(f"/admin/regrade/status/student/{student_netid}")
assert status["processed"] == status["total"]

0 comments on commit d98b974

Please sign in to comment.