Commit bc61e72c by Peter Fogg

Merge pull request #11099 from edx/peter-fogg/remove-verification-deadline-cat

Allow removing a verification deadline through the Commerce API.
parents d2392b45 45bff268
...@@ -59,8 +59,7 @@ class Course(object): ...@@ -59,8 +59,7 @@ class Course(object):
""" Save the CourseMode objects to the database. """ """ Save the CourseMode objects to the database. """
# Override the verification deadline for the course (not the individual modes) # Override the verification deadline for the course (not the individual modes)
if self.verification_deadline is not None: VerificationDeadline.set_deadline(self.id, self.verification_deadline, is_explicit=True)
VerificationDeadline.set_deadline(self.id, self.verification_deadline, is_explicit=True)
for mode in self.modes: for mode in self.modes:
mode.course_id = self.id mode.course_id = self.id
......
...@@ -203,6 +203,29 @@ class CourseRetrieveUpdateViewTests(CourseApiViewTestMixin, ModuleStoreTestCase) ...@@ -203,6 +203,29 @@ class CourseRetrieveUpdateViewTests(CourseApiViewTestMixin, ModuleStoreTestCase)
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(VerificationDeadline.deadline_for_course(self.course.id), verification_deadline) self.assertEqual(VerificationDeadline.deadline_for_course(self.course.id), verification_deadline)
def test_update_remove_verification_deadline(self):
"""
Verify that verification deadlines can be removed through the API.
"""
verification_deadline = datetime(year=1915, month=5, day=7, tzinfo=pytz.utc)
response, __ = self._get_update_response_and_expected_data(None, verification_deadline)
self.assertEqual(VerificationDeadline.deadline_for_course(self.course.id), verification_deadline)
verified_mode = CourseMode(
mode_slug=u'verified',
min_price=200,
currency=u'USD',
sku=u'ABC123',
expiration_datetime=None
)
updated_data = self._serialize_course(self.course, [verified_mode], None)
updated_data['verification_deadline'] = None
response = self.client.put(self.path, json.dumps(updated_data), content_type=JSON_CONTENT_TYPE)
self.assertEqual(response.status_code, 200)
self.assertIsNone(VerificationDeadline.deadline_for_course(self.course.id))
def test_update_overwrite(self): def test_update_overwrite(self):
""" Verify that data submitted via PUT overwrites/deletes modes that are """ Verify that data submitted via PUT overwrites/deletes modes that are
not included in the body of the request. """ not included in the body of the request. """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment