Skip to content

Commit

Permalink
Add ExtraLateDay tests and LateDaysForUser.get() tests [no ci][wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
MattyMay committed Nov 21, 2024
1 parent e2fd933 commit d983971
Show file tree
Hide file tree
Showing 7 changed files with 532 additions and 22 deletions.
8 changes: 6 additions & 2 deletions autograder/core/models/user_late_days.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from autograder.rest_api.serialize_user import serialize_user


class ExtraLateDays(AutograderModel):
objects = AutograderModelManager['ExtraLateDays']()

Expand Down Expand Up @@ -59,7 +60,6 @@ def _days_late(group: Group, submission_timestamp: models.DateTimeField) -> int:

return delta.days + 1 if delta > timedelta() else 0


def to_dict(self):
return {
'user': serialize_user(self.user),
Expand Down Expand Up @@ -109,7 +109,11 @@ def get_many(users_queryset: models.QuerySet, course: Course) -> list["LateDaysF

results = []
for user in users_with_groups:
extra = user.late_days_for_course[0].extra_late_days if user.late_days_for_course else 0
if user.late_days_for_course:
extra = user.late_days_for_course[0].extra_late_days
else:
extra = 0

used = 0

for group in user.groups_with_submissions:
Expand Down
2 changes: 1 addition & 1 deletion autograder/core/tests/test_models/test_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import autograder.core.utils as core_ut
import autograder.utils.testing.model_obj_builders as obj_build
from autograder.core.models import Course, LateDaysRemaining, Semester
from autograder.core.models import Course, Semester
from autograder.core.models.course import clear_cached_user_roles
from autograder.utils.testing import UnitTestBase

Expand Down
Loading

0 comments on commit d983971

Please sign in to comment.