Changeset 9918
- Timestamp:
- 28 Jan 2013, 08:51:46 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
r9799 r9918 1 # -*- coding: utf-8 -*- 1 2 ## $Id$ 2 3 ## … … 112 113 '\n')[0].split(',') 113 114 115 STUDENT_SAMPLE_DATA_EXTASCII = open( 116 os.path.join(os.path.dirname(__file__), 117 'sample_student_data_extascii.csv'), 118 'rb').read() 119 120 STUDENT_HEADER_FIELDS_EXTASCII = STUDENT_SAMPLE_DATA_EXTASCII.split( 121 '\n')[0].split(',') 122 114 123 STUDYLEVEL_SAMPLE_DATA = open( 115 124 os.path.join(os.path.dirname(__file__), 'sample_studylevel_data.csv'), … … 299 308 self.csv_file_duplicates = os.path.join( 300 309 self.workdir, 'sample_student_data_duplicates.csv') 310 self.csv_file_extascii = os.path.join( 311 self.workdir, 'sample_student_data_extascii.csv') 301 312 open(self.csv_file, 'wb').write(STUDENT_SAMPLE_DATA) 302 313 open(self.csv_file_update, 'wb').write(STUDENT_SAMPLE_DATA_UPDATE) … … 306 317 open(self.csv_file_migration, 'wb').write(STUDENT_SAMPLE_DATA_MIGRATION) 307 318 open(self.csv_file_duplicates, 'wb').write(STUDENT_SAMPLE_DATA_DUPLICATES) 319 open(self.csv_file_extascii, 'wb').write(STUDENT_SAMPLE_DATA_EXTASCII) 308 320 309 321 def test_interface(self): … … 394 406 # Two new student_ids have been created. 395 407 self.assertEqual(self.app['students']._curr_stud_id, 1000003) 408 shutil.rmtree(os.path.dirname(fin_file)) 409 410 def test_import_non_ascii(self): 411 self.assertEqual(self.app['students']._curr_stud_id, 1000001) 412 num, num_warns, fin_file, fail_file = self.processor.doImport( 413 self.csv_file_extascii, STUDENT_HEADER_FIELDS_EXTASCII) 414 # Only the Mr. Müßig has been created. Mr. Kinderman's 415 # reg_number has been rejected. 416 self.assertEqual(num_warns,1) 417 content = open(fail_file).read() 418 self.assertEqual( 419 content, 420 'reg_number,firstname,student_id,email,phone,state,' 421 'date_of_birth,lastname,sex,matric_number,--ERRORS--' 422 '\r\n8\xc3\xa4\xc3\xb6\xc3\xbc,Thomas,X222222,aa@aa.ng,' 423 '1234,courses validated,1990-01-02,Kinderman,m,100007,' 424 'reg_number: Invalid text data\r\n' 425 ) 426 self.assertEqual(len(self.app['students']), 1) 427 self.assertEqual(self.app['students']['X111111'].reg_number,'1') 396 428 shutil.rmtree(os.path.dirname(fin_file)) 397 429
Note: See TracChangeset for help on using the changeset viewer.