def test_file_upload_invalid(self): get_response = admin.file_upload() self.request.function = 'edit' self.request._post_vars = Storage({ '_formkey': get_response['form'].formkey, '_formname': get_response['form'].formname }) try: errors = admin.file_upload()['form'].errors self.assertEqual(errors.file, 'Invalid image') except Exception as e: self.fail(('Unexpected exception thrown', e))
def test_file_upload(self): get_response = admin.file_upload() self.request.function = 'edit' self.request._post_vars = Storage({ 'file': upload('file', 'icon_world.jpg'), '_formkey': get_response['form'].formkey, '_formname': get_response['form'].formname }) try: admin.file_upload() except HTTP: pass except Exception: self.fail('Unexpected exception thrown') else: self.fail('No exception thrown')