def test_resource_form_create_invalid(self, mock_open):
dataset = Dataset()
app = self._get_test_app()
env, response = _get_resource_new_page_as_sysadmin(app, dataset['id'])
form = response.forms['resource-edit']
upload = ('upload', 'invalid.csv', INVALID_CSV)
invalid_stream = io.BufferedReader(io.BytesIO(INVALID_CSV))
with mock.patch('io.open', return_value=invalid_stream):
response = webtest_submit(
form, 'save', upload_files=[upload], extra_environ=env)
assert_in('validation', response.body)
assert_in('missing-value', response.body)
assert_in('Row 2 has a missing value in column 4', response.body)
评论列表
文章目录