'Test that when upload validation fails, the proper HTTP response and
messages are returned.'

def test_upload_validation(self, mock_log):

    with make_image_file() as image_file:
        with mock.patch('openedx.core.djangoapps.profile_images.views.validate_uploaded_image', side_effect=ImageValidationError(u'test    error    message')):
            response = self.client.post(self.url, {'file': image_file}, format='multipart')
            self.check_response(response, 400, expected_developer_message=u'test    error    message', expected_user_message=u'test    error    message')
            self.check_images(False)
            self.check_has_profile_image(False)
    self.assertFalse(mock_log.info.called)
    self.assert_no_events_were_emitted()
