'Simulate a donation to a course.
This covers the entire payment flow, except for the external
payment processor, which is simulated.
Arguments:
donation_amount (unicode): The amount the user is donating.
Keyword Arguments:
course_id (CourseKey): If provided, make a donation to the specific course.
Raises:
AssertionError'

def _donate(self, donation_amount, course_id=None):

    params = {'amount': donation_amount}
    if (course_id is not None):
        params['course_id'] = course_id
    url = reverse('donation')
    response = self.client.post(url, params)
    self.assertEqual(response.status_code, 200)
    payment_info = json.loads(response.content)
    self.assertEqual(payment_info['payment_url'], '/shoppingcart/payment_fake')
    if (course_id is not None):
        self.assertEqual(payment_info['payment_params']['merchant_defined_data1'], unicode(course_id))
        self.assertEqual(payment_info['payment_params']['merchant_defined_data2'], 'donation_course')
    else:
        self.assertEqual(payment_info['payment_params']['merchant_defined_data1'], '')
        self.assertEqual(payment_info['payment_params']['merchant_defined_data2'], 'donation_general')
    processor_response_params = PaymentFakeView.response_post_params(payment_info['payment_params'])
    url = reverse('shoppingcart.views.postpay_callback')
    response = self.client.post(url, processor_response_params)
    self.assertRedirects(response, self._receipt_url)
