'Test that the response from get_sale_order_records is in csv format.'

def test_get_sale_order_records_features_csv(self):

    coupon = Coupon(code='test_code', description='test_description', course_id=self.course.id, percentage_discount='10', created_by=self.instructor, is_active=True)
    coupon.save()
    self.cart.order_type = 'business'
    self.cart.save()
    self.cart.add_billing_details(company_name='Test    Company', company_contact_name='Test', company_contact_email='test@123', recipient_name='R1', recipient_email='', customer_reference_number='PO#23')
    paid_course_reg_item = PaidCourseRegistration.add_to_order(self.cart, self.course.id, mode_slug=CourseMode.HONOR)
    resp = self.client.post(reverse('shoppingcart.views.update_user_cart', is_dashboard_endpoint=False), {'ItemId': paid_course_reg_item.id, 'qty': '4'})
    self.assertEqual(resp.status_code, 200)
    resp = self.client.post(reverse('shoppingcart.views.use_code', is_dashboard_endpoint=False), {'code': coupon.code})
    self.assertEqual(resp.status_code, 200)
    self.cart.purchase()
    item = self.cart.orderitem_set.all().select_subclasses()[0]
    coupon_redemption = CouponRedemption.objects.select_related('coupon').filter(order=self.cart)
    sale_order_url = reverse('get_sale_order_records', kwargs={'course_id': self.course.id.to_deprecated_string()})
    response = self.client.post(sale_order_url)
    self.assertEqual(response['Content-Type'], 'text/csv')
    self.assertIn('36', response.content.split('\r\n')[1])
    self.assertIn(str(item.unit_cost), response.content.split('\r\n')[1])
    self.assertIn(str(item.list_price), response.content.split('\r\n')[1])
    self.assertIn(item.status, response.content.split('\r\n')[1])
    self.assertIn(coupon_redemption[0].coupon.code, response.content.split('\r\n')[1])
