'Running on a test case, creating a temp file, uploading it by
calling the corresponding ajax event, and verifying that upload
happens or is rejected as expected.'

def attempt_upload_file_and_verify_result(self, test_case, event_name, content=None):

    if ('magic_number' in test_case):
        f_handler = StringIO.StringIO(test_case['magic_number'].decode('hex'))
    elif (content is not None):
        f_handler = StringIO.StringIO(json.dumps(content, sort_keys=True))
    else:
        f_handler = StringIO.StringIO('')
    f_handler.content_type = test_case['mimetypes']
    f_handler.name = ('file' + test_case['suffixes'])
    url = self.get_handler_url(event_name)
    resp = self.client.post(url, {'file': f_handler})
    self.assertEqual(resp.status_code, test_case['status'])
