Skip to content

Commit

Permalink
Add test for Granting Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
AlirezaT99 committed Jul 24, 2024
1 parent 4ac6226 commit d5d4adf
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions nbgrader/tests/apps/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from os.path import join
from traitlets.config import Config
from datetime import datetime
from datetime import datetime, timedelta

from ...apps.api import NbGraderAPI
from ...coursedir import CourseDirectory
Expand Down Expand Up @@ -310,7 +310,7 @@ def test_get_submission(self, api, course_dir, db):
"id", "name", "student", "last_name", "first_name", "score",
"max_score", "code_score", "max_code_score", "written_score",
"max_written_score", "task_score", "max_task_score", "needs_manual_grade", "autograded",
"timestamp", "submitted", "display_timestamp"])
"timestamp", "submitted", "display_timestamp", "extension"])

default = {
"id": None,
Expand All @@ -330,7 +330,8 @@ def test_get_submission(self, api, course_dir, db):
"autograded": False,
"timestamp": None,
"display_timestamp": None,
"submitted": False
"submitted": False,
"extension": None,
}

s = api.get_submission("ps1", "foo")
Expand Down Expand Up @@ -364,14 +365,15 @@ def test_get_submission(self, api, course_dir, db):
target["written_score"] = 0
target["max_written_score"] = 2
target["needs_manual_grade"] = True
target["extension"] = None
assert s == target

def test_get_submission_no_timestamp(self, api, course_dir, db):
keys = set([
"id", "name", "student", "last_name", "first_name", "score",
"max_score", "code_score", "max_code_score", "written_score",
"max_written_score", "task_score", "max_task_score", "needs_manual_grade", "autograded",
"timestamp", "submitted", "display_timestamp"])
"timestamp", "submitted", "display_timestamp", "extension"])

default = {
"id": None,
Expand All @@ -391,7 +393,8 @@ def test_get_submission_no_timestamp(self, api, course_dir, db):
"autograded": False,
"timestamp": None,
"display_timestamp": None,
"submitted": False
"submitted": False,
"extension": None,
}

s = api.get_submission("ps1", "foo")
Expand Down Expand Up @@ -420,6 +423,7 @@ def test_get_submission_no_timestamp(self, api, course_dir, db):
target["written_score"] = 0
target["max_written_score"] = 2
target["needs_manual_grade"] = True
target["extension"] = None
assert s == target

def test_get_submissions(self, api, course_dir, db):
Expand Down Expand Up @@ -826,3 +830,15 @@ def test_fetch_feedback(self, api, course_dir, db, cache):
result = api.fetch_feedback("ps2", "foo")
assert result["success"]
assert os.path.exists(join("ps2", "feedback", timestamp, "p2.html"))

def test_grant_extension_to_student(self, api, course_dir):
self._copy_file(join("files", "submitted-unchanged.ipynb"), join(course_dir, "source", "ps1", "p1.ipynb"))
self._copy_file(join("files", "submitted-changed.ipynb"), join(course_dir, "submitted", "foo", "ps1", "p1.ipynb"))
api.generate_assignment("ps1")
api.autograde("ps1", "foo")

result = api.grant_extension_to_student("ps1", "foo", 1, 2, 3)
assert result["success"]

extension = api.get_submission("ps1", "foo")["extension"]
assert extension == datetime(1970, 1, 4, 2, 1).isoformat()

0 comments on commit d5d4adf

Please sign in to comment.