Changeset 12996 for main/waeup.kofa/trunk/src/waeup/kofa/students
- Timestamp:
- 23 May 2015, 06:54:24 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py
r12883 r12996 781 781 return None 782 782 p_id = row.get('p_id', None) 783 if p_id i s None:783 if p_id in (None, IGNORE_MARKER): 784 784 return None 785 785 # We can use the hash symbol at the end of p_id in import files … … 846 846 # We have to check p_id. 847 847 p_id = row.get('p_id', None) 848 if not p_id:848 if mode == 'create' and p_id in (None, IGNORE_MARKER): 849 849 timestamp = ("%d" % int(time()*10000))[1:] 850 850 p_id = "p%s" % timestamp 851 851 conv_dict['p_id'] = p_id 852 852 return errs, inv_errs, conv_dict 853 elif p_id in (None, IGNORE_MARKER): 854 errs.append(('p_id','missing')) 855 return errs, inv_errs, conv_dict 853 856 else: 854 857 p_id = p_id.strip('#') 855 if p_id.startswith('p'):856 if not len(p_id) == 14:857 errs.append(('p_id','invalid length'))858 return errs, inv_errs, conv_dict859 elif len(p_id.split('-')) == 3:860 # The SRP used either pins as keys ...861 if len(p_id.split('-')[2]) not in (9, 10):862 errs.append(('p_id','invalid pin'))863 return errs, inv_errs, conv_dict864 else:865 # ... or order_ids.866 if not len(p_id) == 19:867 errs.append(('p_id','invalid format'))868 return errs, inv_errs, conv_dict858 if p_id.startswith('p'): 859 if not len(p_id) == 14: 860 errs.append(('p_id','invalid length')) 861 return errs, inv_errs, conv_dict 862 elif len(p_id.split('-')) == 3: 863 # The SRP used either pins as keys ... 864 if len(p_id.split('-')[2]) not in (9, 10): 865 errs.append(('p_id','invalid pin')) 866 return errs, inv_errs, conv_dict 867 else: 868 # ... or order_ids. 869 if not len(p_id) == 19: 870 errs.append(('p_id','invalid format')) 871 return errs, inv_errs, conv_dict 869 872 # Requirement added on 24/01/2015: p_id must be portal-wide unique. 870 873 if mode == 'create': -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_payment_data.csv
r12623 r12996 4 4 ,paid,schoolfee,p1266236341955,3,2009,19500,BTECHBDT,19500,0615,00,2010/02/15 13:19:01#,online,1 5 5 ,paid,schoolfee,ABC-11-1234567890,3,2011,19500,BTECHBDT,19500.6,,SC,2010/02/15 13:19:01#,sc,1 6 ,paid,schoolfee,<IGNORE>,3,2012,20500,BTECHBDT,20500,0615,00,2020/02/15 13:19:01#,online,1 -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
r12981 r12996 1064 1064 def test_checkConversion(self): 1065 1065 errs, inv_errs, conv_dict = self.processor.checkConversion( 1066 dict(p_id='<IGNORE>'), mode='create') 1067 self.assertEqual(len(errs),0) 1068 errs, inv_errs, conv_dict = self.processor.checkConversion( 1069 dict(p_id='<IGNORE>'), mode='update') 1070 self.assertEqual(len(errs),1) 1071 self.assertEqual(errs[0], ('p_id', u'missing')) 1072 errs, inv_errs, conv_dict = self.processor.checkConversion( 1066 1073 dict(p_id='3816951266236341955')) 1067 1074 self.assertEqual(len(errs),0) … … 1075 1082 dict(p_id='nonsense')) 1076 1083 self.assertEqual(len(errs),1) 1084 self.assertEqual(errs[0], ('p_id', u'invalid format')) 1077 1085 timestamp = ("%d" % int(time()*10000))[1:] 1078 1086 p_id = "p%s" % timestamp … … 1142 1150 # We perform the same import twice, 1143 1151 # the second time in update mode. The number 1144 # of warnings must be the same.1152 # of warnings increases becaus one p_id is missing. 1145 1153 num, num_warns, fin_file, fail_file = self.processor.doImport( 1146 1154 self.csv_file, PAYMENT_HEADER_FIELDS,'create') … … 1148 1156 num, num_warns, fin_file, fail_file = self.processor.doImport( 1149 1157 self.csv_file, PAYMENT_HEADER_FIELDS,'update') 1150 self.assertEqual(num_warns,0) 1151 shutil.rmtree(os.path.dirname(fin_file)) 1158 self.assertEqual(num_warns,1) 1159 content = open(fail_file).read() 1160 shutil.rmtree(os.path.dirname(fin_file)) 1161 self.assertTrue('p_id: missing' in content) 1152 1162 1153 1163 def test_import_remove(self): 1154 1164 # We perform the same import twice, 1155 1165 # the second time in remove mode. The number 1156 # of warnings must be the same.1166 # of warnings increases becaus one p_id is missing. 1157 1167 num, num_warns, fin_file, fail_file = self.processor.doImport( 1158 1168 self.csv_file, PAYMENT_HEADER_FIELDS,'create') … … 1160 1170 num, num_warns, fin_file, fail_file = self.processor.doImport( 1161 1171 self.csv_file, PAYMENT_HEADER_FIELDS,'remove') 1162 self.assertEqual(num_warns,0) 1172 self.assertEqual(num_warns,1) 1173 content = open(fail_file).read() 1174 self.assertTrue('p_id: missing' in content) 1163 1175 shutil.rmtree(os.path.dirname(fin_file)) 1164 1176 logcontent = open(self.logfile).read() … … 1167 1179 in logcontent) 1168 1180 1169 def test_import_ wo_pid(self):1181 def test_import_same_payment_exists(self): 1170 1182 num, num_warns, fin_file, fail_file = self.processor.doImport( 1171 1183 self.csv_file2, PAYMENT_CREATE_HEADER_FIELDS,'create')
Note: See TracChangeset for help on using the changeset viewer.