'Uploading an image with a filename that\'s too long fails.'

def test_upload_long_filename(self):

    thisdir = os.path.dirname(__file__)
    srcfile = os.path.join(thisdir, 'media', 'test.jpg')
    dstfile = os.path.join(thisdir, 'media', (('long_file_name' * 17) + '.jpg'))
    try:
        shutil.copyfile(srcfile, dstfile)
        path = ('kitsune/upload/tests/' + dstfile[len(thisdir):])
        with open(path) as f:
            r = self._make_post_request(image=f)
        eq_(400, r.status_code)
        json_r = json.loads(r.content)
        eq_('error', json_r['status'])
        eq_('Invalid    or    no    image    received.', json_r['message'])
        eq_((MSG_IMAGE_LONG % {'length': 242, 'max': settings.MAX_FILENAME_LENGTH}), json_r['errors']['image'][0])
    finally:
        if os.path.exists(dstfile):
            os.remove(dstfile)
