Skip to content

Commit

Permalink
WIP squash me [no ci]
Browse files Browse the repository at this point in the history
need to rethink how ValidationErrors are raised when
hard_extended_due_date is patched to be before soft_extended_due_date.
Currently the API response will show that the error is from
soft_extended_due_date
  • Loading branch information
MattyMay committed Aug 27, 2024
1 parent 970d734 commit 2479607
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,10 @@ def test_admin_update_group_deprecated_extended_due_date(self):
group = obj_build.make_group(project=self.project)

invalid_extended_due_date = "not a date"
self.do_patch_object_invalid_args_test(
response = self.do_patch_object_invalid_args_test(
group, self.client, self.admin, self.group_url(group),
{'soft_extended_due_date': invalid_extended_due_date})
{'extended_due_date': invalid_extended_due_date})
self.assertIn('soft_extended_due_date', response.data)

self.do_patch_object_test(
group, self.client, self.admin, self.group_url(group),
Expand All @@ -505,15 +506,17 @@ def test_admin_update_soft_extended_due_date(self):
project=self.project, hard_extended_due_date=self.new_due_date)

invalid_soft_extended_due_date = "not a date"
self.do_patch_object_invalid_args_test(
response = self.do_patch_object_invalid_args_test(
group, self.client, self.admin, self.group_url(group),
{'soft_extended_due_date': invalid_soft_extended_due_date})
self.assertIn('soft_extended_due_date', response.data)

# soft_extended_due_date can't be later than hard_extended_due_date
invalid_soft_extended_due_date = self.new_due_date + datetime.timedelta(days=1)
self.do_patch_object_invalid_args_test(
response = self.do_patch_object_invalid_args_test(
group, self.client, self.admin, self.group_url(group),
{'soft_extended_due_date': invalid_soft_extended_due_date})
self.assertIn('soft_extended_due_date', response.data)

valid_soft_extended_due_date = self.new_due_date - datetime.timedelta(days=1)
self.do_patch_object_test(
Expand All @@ -532,15 +535,17 @@ def test_admin_update_hard_extended_due_date(self):
project=self.project, soft_extended_due_date=self.new_due_date)

invalid_hard_extended_due_date = "not a date"
self.do_patch_object_invalid_args_test(
response = self.do_patch_object_invalid_args_test(
group, self.client, self.admin, self.group_url(group),
{'hard_extended_due_date': invalid_hard_extended_due_date})
self.assertIn('hard_extended_due_date', response.data)

# hard_extended_due_date can't be before soft_extended_due_date
invalid_hard_extended_due_date = self.new_due_date - datetime.timedelta(days=1)
self.do_patch_object_invalid_args_test(
response = self.do_patch_object_invalid_args_test(
group, self.client, self.admin, self.group_url(group),
{'hard_extended_due_date': invalid_hard_extended_due_date})
self.assertIn('hard_extended_due_date', response.data)

valid_hard_extended_due_date = self.new_due_date + datetime.timedelta(days=1)
self.do_patch_object_test(
Expand Down Expand Up @@ -578,13 +583,6 @@ def test_admin_update_group_error_non_allowed_domain_guest(self):
{'member_names': [allowed_guest.username, non_allowed_guest.username]})
self.assertIn('members', response.data)

def test_admin_update_group_bad_date(self):
group = obj_build.make_group(project=self.project)
response = self.do_patch_object_invalid_args_test(
group, self.client, self.admin, self.group_url(group),
{'soft_extended_due_date': 'not a date'})
self.assertIn('soft_extended_due_date', response.data)

def test_non_admin_update_group_permission_denied(self):
group = obj_build.make_group(project=self.project)
staff = obj_build.make_staff_user(self.course)
Expand Down

0 comments on commit 2479607

Please sign in to comment.