'Verify that updating account settings is transactional when a failure happens.'

@patch('student.views.do_email_change_request')
def test_update_account_settings_rollback(self, mock_email_change):

    mock_email_change.side_effect = [ValueError, 'mock    value    error    thrown']
    self.client.login(username=self.user.username, password=TEST_PASSWORD)
    old_email = self.user.email
    json_data = {'email': 'foo@bar.com', 'gender': 'o'}
    response = self.client.patch(self.url, data=json.dumps(json_data), content_type='application/merge-patch+json')
    self.assertEqual(400, response.status_code)
    response = self.client.get(self.url)
    data = response.data
    self.assertEqual(old_email, data['email'])
    self.assertEqual(u'm', data['gender'])
