Changeset 8309 for main/waeup.kofa/trunk/src/waeup/kofa/students/tests
- Timestamp:
- 29 Apr 2012, 12:55:52 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students/tests
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
r8289 r8309 37 37 from waeup.kofa.students.student import Student 38 38 from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase 39 from waeup.kofa.interfaces import IBatchProcessor 39 from waeup.kofa.interfaces import IBatchProcessor, FatalCSVError 40 40 41 41 STUDENT_SAMPLE_DATA = open( … … 58 58 59 59 STUDENT_HEADER_FIELDS_UPDATE2 = STUDENT_SAMPLE_DATA_UPDATE2.split( 60 '\n')[0].split(',') 61 62 STUDENT_SAMPLE_DATA_UPDATE3 = open( 63 os.path.join(os.path.dirname(__file__), 'sample_student_data_update3.csv'), 64 'rb').read() 65 66 STUDENT_HEADER_FIELDS_UPDATE3 = STUDENT_SAMPLE_DATA_UPDATE3.split( 67 '\n')[0].split(',') 68 69 STUDENT_SAMPLE_DATA_UPDATE4 = open( 70 os.path.join(os.path.dirname(__file__), 'sample_student_data_update4.csv'), 71 'rb').read() 72 73 STUDENT_HEADER_FIELDS_UPDATE4 = STUDENT_SAMPLE_DATA_UPDATE4.split( 60 74 '\n')[0].split(',') 61 75 … … 179 193 self.csv_file_update2 = os.path.join( 180 194 self.workdir, 'sample_student_data_update2.csv') 195 self.csv_file_update3 = os.path.join( 196 self.workdir, 'sample_student_data_update3.csv') 197 self.csv_file_update4 = os.path.join( 198 self.workdir, 'sample_student_data_update4.csv') 181 199 self.csv_file_migration = os.path.join( 182 200 self.workdir, 'sample_student_data_migration.csv') … … 186 204 open(self.csv_file_update, 'wb').write(STUDENT_SAMPLE_DATA_UPDATE) 187 205 open(self.csv_file_update2, 'wb').write(STUDENT_SAMPLE_DATA_UPDATE2) 206 open(self.csv_file_update3, 'wb').write(STUDENT_SAMPLE_DATA_UPDATE3) 207 open(self.csv_file_update4, 'wb').write(STUDENT_SAMPLE_DATA_UPDATE4) 188 208 open(self.csv_file_migration, 'wb').write(STUDENT_SAMPLE_DATA_MIGRATION) 189 209 open(self.csv_file_duplicates, 'wb').write(STUDENT_SAMPLE_DATA_DUPLICATES) … … 293 313 assert claus.phone is None 294 314 shutil.rmtree(os.path.dirname(fin_file)) 315 316 def test_import_update3(self): 317 num, num_warns, fin_file, fail_file = self.processor.doImport( 318 self.csv_file, STUDENT_HEADER_FIELDS) 319 shutil.rmtree(os.path.dirname(fin_file)) 320 num, num_warns, fin_file, fail_file = self.processor.doImport( 321 self.csv_file_update3, STUDENT_HEADER_FIELDS_UPDATE3, 'update') 322 content = open(fail_file).read() 323 self.assertEqual( 324 content, 325 'reg_number,student_id,transition,--ERRORS--\r\n' 326 '<IGNORE>,X666666,request_clearance,Transition not allowed.\r\n' 327 ) 328 self.assertEqual(num_warns,1) 329 self.assertEqual(self.app['students']['Y777777'].state,'returning') 330 331 def test_import_update4(self): 332 num, num_warns, fin_file, fail_file = self.processor.doImport( 333 self.csv_file, STUDENT_HEADER_FIELDS) 334 shutil.rmtree(os.path.dirname(fin_file)) 335 self.assertRaises( 336 FatalCSVError, self.processor.doImport, self.csv_file_update4, 337 STUDENT_HEADER_FIELDS_UPDATE4, 'update') 295 338 296 339 def test_import_remove(self):
Note: See TracChangeset for help on using the changeset viewer.