From 6123827ab1055f6a931173e364991dc5b1fa789a Mon Sep 17 00:00:00 2001 From: Bill DeRusha Date: Mon, 2 Nov 2015 17:15:09 -0500 Subject: [PATCH] Compare all refund dates in UTC --- common/djangoapps/student/models.py | 4 ++-- common/djangoapps/student/tests/test_refunds.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index e799bcdf9b..2faf03bba4 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -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): diff --git a/common/djangoapps/student/tests/test_refunds.py b/common/djangoapps/student/tests/test_refunds.py index 6c56c9a18a..f495b81bc6 100644 --- a/common/djangoapps/student/tests/test_refunds.py +++ b/common/djangoapps/student/tests/test_refunds.py @@ -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