'test to mock the pdf file generation throws an exception
when generating registration codes.'

def test_pdf_file_throws_exception(self):

    generate_code_url = reverse('generate_registration_codes', kwargs={'course_id': self.course.id.to_deprecated_string()})
    data = {'total_registration_codes': 9, 'company_name': 'Group    Alpha', 'company_contact_name': 'Test@company.com', 'company_contact_email': 'Test@company.com', 'unit_price': 122.45, 'recipient_name': 'Test123', 'recipient_email': 'test@123.com', 'address_line_1': 'Portland    Street', 'address_line_2': '', 'address_line_3': '', 'city': '', 'state': '', 'zip': '', 'country': '', 'customer_reference_number': '123A23F', 'internal_reference': '', 'invoice': ''}
    with patch.object(PDFInvoice, 'generate_pdf', side_effect=Exception):
        response = self.client.post(generate_code_url, data)
        self.assertEqual(response.status_code, 200, response.content)
