def test_get_file_obj_custom_field_name_missing(self): self.request.data = _setupRequestData({ 'fp_upload_field': 'somefield', 'a_field': '{}' }) with self.assertRaisesMessage( ParseError, 'Invalid request data has been provided.'): FilepondFileUploader._get_file_obj(self.request)
def test_get_file_obj_custom_field_name(self): self.request.data = _setupRequestData({ 'fp_upload_field': 'somefield', 'somefield': ['{}'] }) data = FilepondFileUploader._get_file_obj(self.request) self.assertEqual( data, '{}', 'Data was not correctly extracted from ' 'the request.')
def test_get_file_obj_std_field_name(self): # The data may be a byte array, a string ('{}') or an UploadedFile # object depending on what type of filepond request we're handling. # This doesn't actually matter in this and the subsequent get_file_obj # tests, this is just checking that the data is correctly extracted. self.request.data = _setupRequestData({'filepond': '{}'}) data = FilepondFileUploader._get_file_obj(self.request) self.assertEqual( data, '{}', 'Data was not correctly extracted from ' 'the request.')
def test_get_file_obj_std_field_name_missing(self): self.request.data = {'somefield': '{}'} with self.assertRaisesMessage( ParseError, 'Invalid request data has been provided.'): FilepondFileUploader._get_file_obj(self.request)