'Test to remember user invoice copy preference'

def test_user_invoice_copy_preference(self):

    url_reg_code = reverse('generate_registration_codes', kwargs={'course_id': self.course.id.to_deprecated_string()})
    data = {'total_registration_codes': 5, 'company_name': 'Group    Alpha', 'company_contact_name': 'Test@company.com', 'company_contact_email': 'Test@company.com', 'unit_price': 121.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': 'True'}
    response = self.client.post(url_reg_code, data, **{'HTTP_HOST': 'localhost'})
    self.assertEqual(response.status_code, 200, response.content)
    self.assertEqual(response['Content-Type'], 'text/csv')
    url_user_invoice_preference = reverse('get_user_invoice_preference', kwargs={'course_id': self.course.id.to_deprecated_string()})
    response = self.client.post(url_user_invoice_preference, data)
    result = json.loads(response.content)
    self.assertEqual(result['invoice_copy'], True)
    data['invoice'] = ''
    response = self.client.post(url_reg_code, data, **{'HTTP_HOST': 'localhost'})
    self.assertEqual(response.status_code, 200, response.content)
    self.assertEqual(response['Content-Type'], 'text/csv')
    url_user_invoice_preference = reverse('get_user_invoice_preference', kwargs={'course_id': self.course.id.to_deprecated_string()})
    response = self.client.post(url_user_invoice_preference, data)
    result = json.loads(response.content)
    self.assertEqual(result['invoice_copy'], False)
