Commit 69432015 by Peter Fogg

Allow removing upgrade deadlines through the Commerce API.

parent bc61e72c
......@@ -87,8 +87,7 @@ class Course(object):
merged_mode.min_price = posted_mode.min_price
merged_mode.currency = posted_mode.currency
merged_mode.sku = posted_mode.sku
if posted_mode.expiration_datetime is not None:
merged_mode.expiration_datetime = posted_mode.expiration_datetime
merged_mode.expiration_datetime = posted_mode.expiration_datetime
merged_mode.save()
merged_modes.add(merged_mode)
......
""" Commerce API v1 view tests. """
from datetime import datetime
from datetime import datetime, timedelta
import itertools
import json
......@@ -226,6 +226,26 @@ class CourseRetrieveUpdateViewTests(CourseApiViewTestMixin, ModuleStoreTestCase)
self.assertEqual(response.status_code, 200)
self.assertIsNone(VerificationDeadline.deadline_for_course(self.course.id))
def test_remove_upgrade_deadline(self):
"""
Verify that course mode upgrade deadlines can be removed through the API.
"""
# First create a deadline
upgrade_deadline = datetime.now(pytz.utc) + timedelta(days=1)
response, __ = self._get_update_response_and_expected_data(upgrade_deadline, None)
self.assertEqual(response.status_code, 200)
verified_mode = CourseMode.verified_mode_for_course(self.course.id)
self.assertIsNotNone(verified_mode)
self.assertEqual(verified_mode.expiration_datetime.date(), upgrade_deadline.date())
# Now set the deadline to None
response, __ = self._get_update_response_and_expected_data(None, None)
self.assertEqual(response.status_code, 200)
updated_verified_mode = CourseMode.verified_mode_for_course(self.course.id)
self.assertIsNotNone(updated_verified_mode)
self.assertIsNone(updated_verified_mode.expiration_datetime)
def test_update_overwrite(self):
""" Verify that data submitted via PUT overwrites/deletes modes that are
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