- Timestamp:
- 24 Feb 2020, 21:26:35 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
r16000 r16012 496 496 num, num_warns, fin_file, fail_file = self.processor.doImport( 497 497 self.csv_file, STUDENT_HEADER_FIELDS) 498 shutil.rmtree(os.path.dirname(fin_file))499 498 self.assertRaises( 500 499 FatalCSVError, self.processor.doImport, self.csv_file_update4, 501 500 STUDENT_HEADER_FIELDS_UPDATE4, 'update') 501 shutil.rmtree(os.path.dirname(fin_file)) 502 502 503 503 def test_import_remove(self): … … 891 891 dict(reg_number='1', level='100'), self.app) is False 892 892 self.assertEqual(num_warns,3) 893 894 893 shutil.rmtree(os.path.dirname(fin_file)) 895 894 … … 1009 1008 num, num_warns, fin_file, fail_file = self.processor.doImport( 1010 1009 self.csv_file, COURSETICKET_HEADER_FIELDS,'create') 1011 shutil.rmtree(os.path.dirname(fin_file))1012 1010 num, num_warns, fin_file, fail_file = self.processor.doImport( 1013 1011 self.csv_file, COURSETICKET_HEADER_FIELDS,'update') … … 1065 1063 '1,COURSE1,<IGNORE>,300,2008,<IGNORE>,6,<IGNORE>,<IGNORE>,level object: does not exist\r\n' 1066 1064 '1,COURSE1,<IGNORE>,300,2008X,<IGNORE>,6,<IGNORE>,<IGNORE>,level_session: Invalid value\r\n') 1065 shutil.rmtree(os.path.dirname(fin_file)) 1066 1067 def test_import_create_locked(self): 1068 # In state 'transcript validated' course tickets can't be created 1069 student = self.app['students']['X666666'] 1070 IWorkflowState(student).setState('transcript validated') 1071 num, num_warns, fin_file, fail_file = self.processor.doImport( 1072 self.csv_file, COURSETICKET_HEADER_FIELDS,'create') 1073 fail_file = open(fail_file).read() 1074 self.assertEqual(num_warns,7) 1075 self.assertEqual(fail_file, 1076 'reg_number,code,mandatory,level,level_session,ticket_session,score,unlock_score,matric_number,--ERRORS--\r\n' 1077 '1,COURSE1,True,100,<IGNORE>,<IGNORE>,1,<IGNORE>,<IGNORE>,Studycourse is locked.\r\n' 1078 '1,COURSE1,True,200,2008,<IGNORE>,1,<IGNORE>,<IGNORE>,Studycourse is locked.\r\n' 1079 '1,COURSE1,<IGNORE>,nonsense,<IGNORE>,<IGNORE>,5,<IGNORE>,<IGNORE>,Not all parents do exist yet.\r\n' 1080 '1,NONSENSE,<IGNORE>,100,<IGNORE>,<IGNORE>,5,<IGNORE>,<IGNORE>,code: non-existent\r\n' 1081 '1,COURSE1,<IGNORE>,200,2004,<IGNORE>,6,<IGNORE>,<IGNORE>,level_session: does not match 2008\r\n' 1082 '1,COURSE1,<IGNORE>,300,2008,<IGNORE>,6,<IGNORE>,<IGNORE>,level object: does not exist\r\n' 1083 '1,COURSE1,<IGNORE>,300,2008X,<IGNORE>,6,<IGNORE>,<IGNORE>,level_session: Invalid value\r\n') 1084 self.assertFalse(self.processor.entryExists( 1085 dict(reg_number='1', level='100', code='COURSE1'), 1086 self.app)) 1087 shutil.rmtree(os.path.dirname(fin_file)) 1088 1089 def test_import_remove_locked(self): 1090 # We perform the same import twice, 1091 # the second time in remove mode. 1092 num, num_warns, fin_file, fail_file = self.processor.doImport( 1093 self.csv_file, COURSETICKET_HEADER_FIELDS,'create') 1094 shutil.rmtree(os.path.dirname(fin_file)) 1095 assert self.processor.entryExists( 1096 dict(reg_number='1', level='100', code='COURSE1'), self.app) is True 1097 # In state 'transcript validated' course tickets can't be removed 1098 student = self.app['students']['X666666'] 1099 IWorkflowState(student).setState('transcript validated') 1100 num, num_warns, fin_file, fail_file = self.processor.doImport( 1101 self.csv_file, COURSETICKET_HEADER_FIELDS,'remove') 1102 self.assertEqual(num_warns,7) 1103 assert self.processor.entryExists( 1104 dict(reg_number='1', level='100', code='COURSE1'), self.app) is True 1105 logcontent = open(self.logfile).read() 1106 self.assertFalse( 1107 'INFO - system - X666666 - Course ticket in 100 removed: COURSE1' 1108 in logcontent) 1109 fail_file = open(fail_file).read() 1110 self.assertEqual(fail_file, 1111 'reg_number,code,matric_number,level,--ERRORS--\r\n' 1112 '1,COURSE1,<IGNORE>,100,Studycourse is locked.\r\n' 1113 '1,COURSE1,<IGNORE>,200,Studycourse is locked.\r\n' 1114 '1,COURSE1,<IGNORE>,nonsense,Cannot remove: no such entry\r\n' 1115 '1,NONSENSE,<IGNORE>,100,Cannot remove: no such entry\r\n' 1116 '1,COURSE1,<IGNORE>,200,Studycourse is locked.\r\n' 1117 '1,COURSE1,<IGNORE>,300,Cannot remove: no such entry\r\n' 1118 '1,COURSE1,<IGNORE>,300,Cannot remove: no such entry\r\n' 1119 ) 1067 1120 shutil.rmtree(os.path.dirname(fin_file)) 1068 1121 … … 1374 1427 '... INFO - system - X666666 - Returned...', 1375 1428 logcontent) 1376 1377 1429 shutil.rmtree(os.path.dirname(fin_file)) 1378 1430
Note: See TracChangeset for help on using the changeset viewer.