'Test to download a response of all the active coupon codes'

def test_get_historical_coupon_codes(self):

    get_coupon_code_url = reverse('get_coupon_codes', kwargs={'course_id': self.course.id.to_deprecated_string()})
    for i in range(10):
        coupon = Coupon(code='test_code{0}'.format(i), description='test_description', course_id=self.course.id, percentage_discount='{0}'.format(i), created_by=self.instructor, is_active=True)
        coupon.save()
    for i in range(5):
        coupon = Coupon(code='coupon{0}'.format(i), description='test_description', course_id=self.course.id, percentage_discount='{0}'.format(i), created_by=self.instructor, is_active=True, expiration_date=(datetime.datetime.now(pytz.UTC) + datetime.timedelta(days=2)))
        coupon.save()
    response = self.client.post(get_coupon_code_url)
    self.assertEqual(response.status_code, 200, response.content)
    for coupon in Coupon.objects.all():
        self.assertIn('"{coupon_code}","{course_id}","{discount}","{description}","{expiration_date}","{is_active}","{code_redeemed_count}","{total_discounted_seats}","{total_discounted_amount}"'.format(coupon_code=coupon.code, course_id=coupon.course_id, discount=coupon.percentage_discount, description=coupon.description, expiration_date=coupon.display_expiry_date, is_active=coupon.is_active, code_redeemed_count='0', total_discounted_seats='0', total_discounted_amount='0'), response.content)
    self.assertEqual(response['Content-Type'], 'text/csv')
    body = response.content.replace('\r', '')
    self.assertTrue(body.startswith(EXPECTED_COUPON_CSV_HEADER))
