Fix #934: Error in motion import with bad csv file.

This commit is contained in:
Norman Jäckel 2013-10-22 00:17:56 +02:00
parent b0b91e94c0
commit 6175ce25c5
2 changed files with 5 additions and 2 deletions

View File

@ -46,7 +46,7 @@ def import_motions(csv_file, default_submitter, override=False, importing_person
try: try:
csv_file.read().decode('utf8') csv_file.read().decode('utf8')
except UnicodeDecodeError: except UnicodeDecodeError:
return (0, [_('Import file has wrong character encoding, only UTF-8 is supported!')], []) return (0, 0, [_('Import file has wrong character encoding, only UTF-8 is supported!')], [])
csv_file.seek(0) csv_file.seek(0)
with transaction.commit_on_success(): with transaction.commit_on_success():

View File

@ -93,6 +93,9 @@ class CSVImport(TestCase):
text = u'Müller'.encode('iso-8859-15') text = u'Müller'.encode('iso-8859-15')
csv_file.write(text) csv_file.write(text)
csv_file.seek(0) csv_file.seek(0)
count_success, error_messages, warning_messages = import_motions(csv_file=csv_file, default_submitter=self.normal_user.person_id) count_success, count_lines, error_messages, warning_messages = import_motions(
csv_file=csv_file,
default_submitter=self.normal_user.person_id)
self.assertEqual(count_success, 0) self.assertEqual(count_success, 0)
self.assertEqual(count_lines, 0)
self.assertTrue('Import file has wrong character encoding, only UTF-8 is supported!' in error_messages) self.assertTrue('Import file has wrong character encoding, only UTF-8 is supported!' in error_messages)