'Assert that the later date is used with the configurable refund period in calculating the returned cutoff date.'

@ddt.data((timedelta(days=1), timedelta(days=2), timedelta(days=2), 14), (timedelta(days=2), timedelta(days=1), timedelta(days=2), 14), (timedelta(days=1), timedelta(days=2), timedelta(days=2), 1), (timedelta(days=2), timedelta(days=1), timedelta(days=2), 1))
@ddt.unpack
@httpretty.activate
@override_settings(ECOMMERCE_API_URL=TEST_API_URL)
def test_refund_cutoff_date(self, order_date_delta, course_start_delta, expected_date_delta, days):

    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)
    refund_period = timedelta(days=days)
    expected_content = '{{"date_placed":    "{date}"}}'.format(date=order_date.strftime(ECOMMERCE_DATE_FORMAT))
    httpretty.register_uri(httpretty.GET, '{url}/orders/{order}/'.format(url=TEST_API_URL, order=self.ORDER_NUMBER), status=200, body=expected_content, adding_headers={'Content-Type': JSON})
    self.enrollment.course_overview.start = course_start
    self.enrollment.attributes.add(CourseEnrollmentAttribute(enrollment=self.enrollment, namespace='order', name='order_number', value=self.ORDER_NUMBER))
    with patch('student.models.EnrollmentRefundConfiguration.current') as config:
        instance = config.return_value
        instance.refund_window = refund_period
        self.assertEqual(self.enrollment.refund_cutoff_date(), (expected_date + refund_period))
