Commit f4dc1f33 by Bill DeRusha

Merge pull request #10471 from edx/bderusha/refund-follow-on

Compare all refund dates in UTC
parents 36f05c86 6123827a
......@@ -1377,7 +1377,7 @@ class CourseEnrollment(models.Model):
# If it is after the refundable cutoff date they should not be refunded.
refund_cutoff_date = self.refund_cutoff_date()
if refund_cutoff_date and datetime.now() > refund_cutoff_date:
if refund_cutoff_date and datetime.now(UTC) > refund_cutoff_date:
return False
course_mode = CourseMode.mode_for_course(self.course_id, 'verified')
......@@ -1400,7 +1400,7 @@ class CourseEnrollment(models.Model):
self.course_overview.start.replace(tzinfo=None)
)
return refund_window_start_date + EnrollmentRefundConfiguration.current().refund_window
return refund_window_start_date.replace(tzinfo=UTC) + EnrollmentRefundConfiguration.current().refund_window
@property
def username(self):
......
......@@ -113,10 +113,10 @@ class RefundableTest(SharedModuleStoreTestCase):
self.assertTrue(self.enrollment.refundable())
with patch('student.models.CourseEnrollment.refund_cutoff_date') as cutoff_date:
cutoff_date.return_value = datetime.now() - timedelta(days=1)
cutoff_date.return_value = datetime.now(pytz.UTC) - timedelta(minutes=5)
self.assertFalse(self.enrollment.refundable())
cutoff_date.return_value = datetime.now() + timedelta(days=1)
cutoff_date.return_value = datetime.now(pytz.UTC) + timedelta(minutes=5)
self.assertTrue(self.enrollment.refundable())
@ddt.data(
......@@ -132,7 +132,7 @@ class RefundableTest(SharedModuleStoreTestCase):
"""
Assert that the later date is used with the configurable refund period in calculating the returned cutoff date.
"""
now = datetime.now().replace(microsecond=0)
now = datetime.now(pytz.UTC).replace(microsecond=0)
order_date = now + order_date_delta
course_start = now + course_start_delta
expected_date = now + expected_date_delta
......
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