Skip to content

Commit

Permalink
Fix/repurpose late days views tests [WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
MattyMay committed Nov 21, 2024
1 parent 3e50d45 commit 294e6a2
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions autograder/rest_api/tests/test_views/test_user_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,20 @@ def setUp(self):
self.initial_num_late_days = 4
self.course = obj_build.make_course(num_late_days=self.initial_num_late_days)

def test_student_view_own_late_day_count(self):
def test_student_view_own_late_days(self):
student = obj_build.make_student_user(self.course)
self.do_get_late_days_test(student, student, self.course, 0, 0)

def test_guest_view_own_late_day_count(self):
def test_guest_view_own_late_days(self):
guest = obj_build.make_user()
self.do_get_late_days_test(guest, guest, self.course, 0, 0)

def test_staff_view_other_late_day_count(self):
def test_staff_view_other_students_late_days(self):
staff = obj_build.make_staff_user(self.course)
student = obj_build.make_student_user(self.course)
self.do_get_late_days_test(staff, student, self.course, 0, 0)

def test_admin_change_extra_late_days_by_pk(self):
self.maxDiff=None
admin = obj_build.make_admin_user(self.course)
student = obj_build.make_student_user(self.course)

Expand Down Expand Up @@ -275,7 +274,7 @@ def test_admin_change_extra_late_days_by_username(self):
self.assertEqual({
'extra_late_days': 42,
'late_days_used': 0,
'late_days_remainig': self.course.num_late_days + 42,
'late_days_remaining': self.course.num_late_days + 42,
'user': serialize_user(student),
'course': self.course.to_dict()
}, response.data)
Expand Down Expand Up @@ -305,7 +304,7 @@ def test_admin_change_extra_late_days_by_pk_object_exists(self):
extra = ag_models.ExtraLateDays.objects.get(user=student, course=self.course)
self.assertEqual(27, extra.extra_late_days)

def test_admin_change_late_day_count_by_username_object_exists(self):
def test_admin_change_extra_late_days_by_username_object_exists(self):
admin = obj_build.make_admin_user(self.course)
student = obj_build.make_student_user(self.course)

Expand Down Expand Up @@ -356,7 +355,7 @@ def test_admin_change_extra_late_days_for_other_course_permission_denied(self):
{'extra_late_days': 7})
self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code)

def test_staff_view_late_day_count_for_other_course_permission_denied(self):
def test_staff_view_late_days_for_other_course_permission_denied(self):
staff = obj_build.make_staff_user(self.course)

# Student for other course
Expand All @@ -379,7 +378,7 @@ def test_staff_view_late_day_count_for_other_course_permission_denied(self):
response = self.client.get(self.get_username_url(other_guest, other_course))
self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code)

def test_student_view_other_late_day_count_permission_denied(self):
def test_student_view_other_users_late_days_permission_denied(self):
student1 = obj_build.make_student_user(self.course)
student2 = obj_build.make_student_user(self.course)

Expand All @@ -390,7 +389,7 @@ def test_student_view_other_late_day_count_permission_denied(self):
response = self.client.get(self.get_username_url(student2, self.course))
self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code)

def test_guest_view_other_late_day_count_permission_denied(self):
def test_guest_view_other_users_late_days_denied(self):
guest1 = obj_build.make_user()
guest2 = obj_build.make_user()

Expand All @@ -402,17 +401,20 @@ def test_guest_view_other_late_day_count_permission_denied(self):
self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code)

def test_get_late_day_count_object_exists(self):
# TODO: fix test or implementation, fix name (doesn't really make sense)
# maybe write another test for when ExtraLateDays exists
self.maxDiff = None
base_time = pytz.utc.localize(datetime.now()),
base_time = datetime.now()
group = obj_build.build_group(
project_kwargs={
'course': self.course,
'closing_time': base_time,
'closing_time': base_time
}
)

student = group.members.first()
sub = obj_build.make_finished_submission(group=group, submission_kwargs={
'timestamp': group.project.closing_time + timedelta(days=1)
obj_build.make_finished_submission(group=group, submission_kwargs={
'timestamp': base_time + timedelta(days=1)
})

self.do_get_late_days_test(
Expand Down

0 comments on commit 294e6a2

Please sign in to comment.