- Timestamp:
- 21 Mar 2012, 13:42:00 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/batching.py
r7811 r7933 30 30 IApplicantsContainer, IApplicant, IApplicantUpdateByRegNo) 31 31 32 class ApplicantsContainer Importer(BatchProcessor):33 """A n importer for applicants containers.32 class ApplicantsContainerProcessor(BatchProcessor): 33 """A processor for applicants containers. 34 34 """ 35 35 grok.implements(IBatchProcessor) 36 36 grok.provides(IBatchProcessor) 37 37 grok.context(Interface) 38 util_name = 'applicants container importer'38 util_name = 'applicants container processor' 39 39 grok.name(util_name) 40 40 41 name = u'Applicants Container Importer'41 name = u'Applicants Container Processor' 42 42 mode = u'create' 43 43 iface = IApplicantsContainer … … 71 71 return 72 72 73 class Applicant Importer(BatchProcessor):73 class ApplicantProcessor(BatchProcessor): 74 74 """A batch processor for IApplicant objects. 75 75 """ … … 77 77 grok.provides(IBatchProcessor) 78 78 grok.context(Interface) 79 util_name = 'applicant importer'79 util_name = 'applicantprocessor' 80 80 grok.name(util_name) 81 name = u'Applicant Importer'81 name = u'Applicant Processor' 82 82 iface = IApplicant 83 83 location_fields = [] -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py
r7915 r7933 354 354 355 355 This is a base interface with no field 356 required. For use with importers, forms, etc., please use one of356 required. For use with processors, forms, etc., please use one of 357 357 the derived interfaces below, which set more fields to required 358 358 state, depending on use-case. -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_batching.py
r7912 r7933 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 """Unit tests for applicants-related data importers.18 """Unit tests for applicants-related data processors. 19 19 """ 20 20 import datetime … … 29 29 from waeup.kofa.app import University 30 30 from waeup.kofa.applicants.batching import ( 31 ApplicantsContainer Importer, ApplicantImporter)31 ApplicantsContainerProcessor, ApplicantProcessor) 32 32 from waeup.kofa.applicants.container import ApplicantsContainer 33 33 from waeup.kofa.applicants.applicant import Applicant … … 66 66 '\n')[0].split(',') 67 67 68 class ApplicantsContainer ImporterTest(FunctionalTestCase):68 class ApplicantsContainerProcessorTest(FunctionalTestCase): 69 69 70 70 layer = FunctionalLayer 71 71 72 72 def setUp(self): 73 super(ApplicantsContainer ImporterTest, self).setUp()73 super(ApplicantsContainerProcessorTest, self).setUp() 74 74 75 75 # Setup a sample site for each test … … 85 85 self.app['applicants']['dp2011'] = self.container 86 86 87 self. importer = ApplicantsContainerImporter()87 self.processor = ApplicantsContainerProcessor() 88 88 self.workdir = tempfile.mkdtemp() 89 89 self.csv_file = os.path.join(self.workdir, 'sampledata.csv') … … 93 93 94 94 def tearDown(self): 95 super(ApplicantsContainer ImporterTest, self).tearDown()95 super(ApplicantsContainerProcessorTest, self).tearDown() 96 96 shutil.rmtree(self.workdir) 97 97 shutil.rmtree(self.dc_root) … … 101 101 def test_interface(self): 102 102 # Make sure we fulfill the interface contracts. 103 assert verifyObject(IBatchProcessor, self. importer) is True103 assert verifyObject(IBatchProcessor, self.processor) is True 104 104 assert verifyClass( 105 IBatchProcessor, ApplicantsContainer Importer) is True105 IBatchProcessor, ApplicantsContainerProcessor) is True 106 106 107 107 def test_parentsExist(self): 108 assert self. importer.parentsExist(None, dict()) is False109 assert self. importer.parentsExist(None, self.app) is True108 assert self.processor.parentsExist(None, dict()) is False 109 assert self.processor.parentsExist(None, self.app) is True 110 110 111 111 def test_entryExists(self): 112 assert self. importer.entryExists(112 assert self.processor.entryExists( 113 113 dict(code='REG_NONE'), self.app) is False 114 assert self. importer.entryExists(114 assert self.processor.entryExists( 115 115 dict(code='dp2011'), self.app) is True 116 116 117 117 def test_getParent(self): 118 parent = self. importer.getParent(None, self.app)118 parent = self.processor.getParent(None, self.app) 119 119 assert parent is self.app['applicants'] 120 120 121 121 def test_getEntry(self): 122 assert self. importer.getEntry(122 assert self.processor.getEntry( 123 123 dict(code='REG_NONE'), self.app) is None 124 assert self. importer.getEntry(124 assert self.processor.getEntry( 125 125 dict(code='dp2011'), self.app) is self.container 126 126 127 127 def test_addEntry(self): 128 self. importer.addEntry(128 self.processor.addEntry( 129 129 'New application', dict(code='dp2012'), self.app) 130 130 assert self.app['applicants']['dp2012'] == 'New application' 131 131 132 132 def test_delEntry(self): 133 self. importer.delEntry(dict(code='dp2011'), self.app)133 self.processor.delEntry(dict(code='dp2011'), self.app) 134 134 assert 'dp2011' not in self.app['applicants'].keys() 135 135 … … 137 137 # Do a real import 138 138 # see local sample_container.csv file for input 139 num, num_warns, fin_file, fail_file = self. importer.doImport(139 num, num_warns, fin_file, fail_file = self.processor.doImport( 140 140 self.csv_file, APPS_CONTAINER_HEADER_FIELDS) 141 141 avail_containers = [x for x in self.app['applicants'].keys()] … … 219 219 return 220 220 221 class Applicant ImporterTest(ApplicantImportExportSetup):221 class ApplicantProcessorTest(ApplicantImportExportSetup): 222 222 223 223 layer = FunctionalLayer 224 224 225 225 def setUp(self): 226 super(Applicant ImporterTest, self).setUp()227 self. importer = ApplicantImporter()226 super(ApplicantProcessorTest, self).setUp() 227 self.processor = ApplicantProcessor() 228 228 self.csv_file = os.path.join(self.workdir, 'sample_applicant_data.csv') 229 229 self.csv_file_faulty = os.path.join(self.workdir, … … 237 237 def test_interface(self): 238 238 # Make sure we fulfill the interface contracts. 239 assert verifyObject(IBatchProcessor, self. importer) is True239 assert verifyObject(IBatchProcessor, self.processor) is True 240 240 assert verifyClass( 241 IBatchProcessor, Applicant Importer) is True241 IBatchProcessor, ApplicantProcessor) is True 242 242 243 243 def test_entryExists(self): 244 assert self. importer.entryExists(244 assert self.processor.entryExists( 245 245 dict(container_code='dp2011', application_number='999'), 246 246 self.app) is False 247 247 248 248 def test_getEntry(self): 249 applicant = self. importer.getEntry(249 applicant = self.processor.getEntry( 250 250 dict(container_code='dp2011', 251 251 application_number=self.application_number), self.app) … … 254 254 def test_addEntry(self): 255 255 new_applicant = Applicant() 256 self. importer.addEntry(256 self.processor.addEntry( 257 257 new_applicant, dict(container_code='dp2011'), self.app) 258 258 assert len(self.app['applicants']['dp2011'].keys()) == 2 … … 261 261 assert self.application_number in self.app[ 262 262 'applicants']['dp2011'].keys() 263 self. importer.delEntry(263 self.processor.delEntry( 264 264 dict(container_code='dp2011', 265 265 application_number=self.application_number), self.app) … … 268 268 269 269 def test_import(self): 270 num, num_warns, fin_file, fail_file = self. importer.doImport(270 num, num_warns, fin_file, fail_file = self.processor.doImport( 271 271 self.csv_file, APPLICANT_HEADER_FIELDS) 272 272 self.assertEqual(num_warns,0) … … 285 285 # when in format xx/yy/zzzz as we cannot say whether it is 286 286 # meant as dd/mm/yyyy or mm/dd/yyyy. We therefore require yyyy-mm-dd 287 num, num_warns, fin_file, fail_file = self. importer.doImport(287 num, num_warns, fin_file, fail_file = self.processor.doImport( 288 288 self.csv_file_faulty, APPLICANT_HEADER_FIELDS) 289 289 if fail_file is not None: … … 300 300 301 301 def test_import_update(self): 302 num, num_warns, fin_file, fail_file = self. importer.doImport(302 num, num_warns, fin_file, fail_file = self.processor.doImport( 303 303 self.csv_file, APPLICANT_HEADER_FIELDS) 304 304 shutil.rmtree(os.path.dirname(fin_file)) 305 num, num_warns, fin_file, fail_file = self. importer.doImport(305 num, num_warns, fin_file, fail_file = self.processor.doImport( 306 306 self.csv_file_update, APPLICANT_HEADER_FIELDS_UPDATE, 'update') 307 307 self.assertEqual(num_warns,0) … … 309 309 310 310 def test_import_remove(self): 311 num, num_warns, fin_file, fail_file = self. importer.doImport(311 num, num_warns, fin_file, fail_file = self.processor.doImport( 312 312 self.csv_file, APPLICANT_HEADER_FIELDS) 313 313 shutil.rmtree(os.path.dirname(fin_file)) 314 num, num_warns, fin_file, fail_file = self. importer.doImport(314 num, num_warns, fin_file, fail_file = self.processor.doImport( 315 315 self.csv_file_update, APPLICANT_HEADER_FIELDS_UPDATE, 'remove') 316 316 self.assertEqual(num_warns,0) -
main/waeup.kofa/trunk/src/waeup/kofa/browser/batchprocessing.txt
r7811 r7933 93 93 >>> importerselect = browser.getControl(name='importer') 94 94 >>> importerselect.displayOptions 95 ['Applicant Importer',96 'Applicants Container Importer',97 'CourseTicket Importer',98 'Payment Importer',99 'Student Importer',100 'StudentStudyCourse Importer (update only)',101 'StudentStudyLevel Importer',102 'CertificateCourse Importer',103 'Certificate Importer',104 'Course Importer',105 'Department Importer',106 'Faculty Importer']107 108 >>> importerselect.getControl('Faculty Importer').selected = True95 ['Applicant Processor', 96 'Applicants Container Processor', 97 'CourseTicket Processor', 98 'Payment Processor', 99 'Student Processor', 100 'StudentStudyCourse Processor (update only)', 101 'StudentStudyLevel Processor', 102 'CertificateCourse Processor', 103 'Certificate Processor', 104 'Course Processor', 105 'Department Processor', 106 'Faculty Processor'] 107 108 >>> importerselect.getControl('Faculty Processor').selected = True 109 109 110 110 >>> modeselect = browser.getControl(name='mode') … … 197 197 198 198 >>> importerselect = browser.getControl(name='importer') 199 >>> importerselect.getControl('Department Importer').selected = True199 >>> importerselect.getControl('Department Processor').selected = True 200 200 >>> modeselect = browser.getControl(name='mode') 201 201 >>> modeselect.getControl(value='create').selected = True … … 262 262 263 263 >>> importerselect = browser.getControl(name='importer') 264 >>> importerselect.getControl('Course Importer', index=2).selected = True264 >>> importerselect.getControl('Course Processor', index=2).selected = True 265 265 >>> modeselect = browser.getControl(name='mode') 266 266 >>> modeselect.getControl(value='create').selected = True … … 328 328 329 329 >>> importerselect = browser.getControl(name='importer') 330 >>> importerselect.getControl('Certificate Importer').selected = True330 >>> importerselect.getControl('Certificate Processor').selected = True 331 331 >>> modeselect = browser.getControl(name='mode') 332 332 >>> modeselect.getControl(value='create').selected = True … … 393 393 394 394 >>> importerselect = browser.getControl(name='importer') 395 >>> importerselect.getControl('CertificateCourse Importer').selected = True395 >>> importerselect.getControl('CertificateCourse Processor').selected = True 396 396 >>> modeselect = browser.getControl(name='mode') 397 397 >>> modeselect.getControl(value='create').selected = True … … 466 466 467 467 >>> importerselect = browser.getControl(name='importer') 468 >>> importerselect.getControl('Faculty Importer').selected = True468 >>> importerselect.getControl('Faculty Processor').selected = True 469 469 >>> modeselect = browser.getControl(name='mode') 470 470 >>> modeselect.getControl(value='create').selected = True … … 528 528 529 529 >>> importerselect = browser.getControl(name='importer') 530 >>> importerselect.getControl('Faculty Importer').selected = True530 >>> importerselect.getControl('Faculty Processor').selected = True 531 531 >>> modeselect = browser.getControl(name='mode') 532 532 >>> modeselect.getControl(value='create').selected = True -
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r7908 r7933 829 829 830 830 class DatacenterImportStep2(KofaPage): 831 """Manual import step 2: choose importer831 """Manual import step 2: choose processor 832 832 """ 833 833 grok.context(IDataCenter) -
main/waeup.kofa/trunk/src/waeup/kofa/datacenter.py
r7819 r7933 133 133 If finished file is placed in a location outside the local 134 134 storage dir, the complete directory is removed 135 afterwards. Regular importers should put their stuff in135 afterwards. Regular processors should put their stuff in 136 136 dedicated temporary dirs. 137 137 -
main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py
r7932 r7933 321 321 """ 322 322 name = schema.TextLine( 323 title = _(u' Importer name')323 title = _(u'Processor name') 324 324 ) 325 325 -
main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py
r7811 r7933 49 49 grok.provides(IBatchProcessor) 50 50 grok.context(Interface) 51 util_name = 'student importer'51 util_name = 'studentprocessor' 52 52 grok.name(util_name) 53 53 54 name = u'Student Importer'54 name = u'Student Processor' 55 55 iface = IStudent 56 56 … … 223 223 grok.name(util_name) 224 224 225 name = u'StudentStudyCourse Importer (update only)'225 name = u'StudentStudyCourse Processor (update only)' 226 226 iface = IStudentStudyCourse 227 227 factory_name = 'waeup.StudentStudyCourse' … … 330 330 grok.provides(IBatchProcessor) 331 331 grok.context(Interface) 332 util_name = 'studylevel importer'332 util_name = 'studylevelprocessor' 333 333 grok.name(util_name) 334 334 335 name = u'StudentStudyLevel Importer'335 name = u'StudentStudyLevel Processor' 336 336 iface = IStudentStudyLevel 337 337 factory_name = 'waeup.StudentStudyLevel' … … 427 427 grok.provides(IBatchProcessor) 428 428 grok.context(Interface) 429 util_name = 'courseticket importer'429 util_name = 'courseticketprocessor' 430 430 grok.name(util_name) 431 431 432 name = u'CourseTicket Importer'432 name = u'CourseTicket Processor' 433 433 iface = ICourseTicket 434 434 factory_name = 'waeup.CourseTicket' … … 533 533 grok.provides(IBatchProcessor) 534 534 grok.context(Interface) 535 util_name = 'payment importer'535 util_name = 'paymentprocessor' 536 536 grok.name(util_name) 537 537 538 name = u'Payment Importer'538 name = u'Payment Processor' 539 539 iface = IStudentOnlinePayment 540 540 factory_name = 'waeup.StudentOnlinePayment' -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
r7811 r7933 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 """Unit tests for students-related data importers.18 """Unit tests for students-related data processors. 19 19 """ 20 20 import os … … 95 95 '\n')[0].split(',') 96 96 97 class Student ImporterTest(FunctionalTestCase):97 class StudentProcessorTest(FunctionalTestCase): 98 98 99 99 layer = FunctionalLayer 100 100 101 101 def setUp(self): 102 super(Student ImporterTest, self).setUp()102 super(StudentProcessorTest, self).setUp() 103 103 # Setup a sample site for each test 104 104 app = University() … … 124 124 self.app['students'].addStudent(student) 125 125 self.student = self.app['students'][student.student_id] 126 self. importer = StudentProcessor()126 self.processor = StudentProcessor() 127 127 self.workdir = tempfile.mkdtemp() 128 128 self.csv_file = os.path.join(self.workdir, 'sample_student_data.csv') … … 139 139 140 140 def tearDown(self): 141 super(Student ImporterTest, self).tearDown()141 super(StudentProcessorTest, self).tearDown() 142 142 shutil.rmtree(self.workdir) 143 143 shutil.rmtree(self.dc_root) … … 147 147 def test_interface(self): 148 148 # Make sure we fulfill the interface contracts. 149 assert verifyObject(IBatchProcessor, self. importer) is True149 assert verifyObject(IBatchProcessor, self.processor) is True 150 150 assert verifyClass( 151 151 IBatchProcessor, StudentProcessor) is True 152 152 153 153 def test_parentsExist(self): 154 self.assertFalse(self. importer.parentsExist(None, dict()))155 self.assertTrue(self. importer.parentsExist(None, self.app))154 self.assertFalse(self.processor.parentsExist(None, dict())) 155 self.assertTrue(self.processor.parentsExist(None, self.app)) 156 156 157 157 def test_entryExists(self): 158 assert self. importer.entryExists(158 assert self.processor.entryExists( 159 159 dict(student_id='ID_NONE'), self.app) is False 160 assert self. importer.entryExists(160 assert self.processor.entryExists( 161 161 dict(reg_number='123'), self.app) is True 162 162 163 163 def test_getParent(self): 164 parent = self. importer.getParent(None, self.app)164 parent = self.processor.getParent(None, self.app) 165 165 assert parent is self.app['students'] 166 166 167 167 def test_getEntry(self): 168 assert self. importer.getEntry(168 assert self.processor.getEntry( 169 169 dict(student_id='ID_NONE'), self.app) is None 170 assert self. importer.getEntry(170 assert self.processor.getEntry( 171 171 dict(student_id=self.student.student_id), self.app) is self.student 172 172 173 173 def test_addEntry(self): 174 174 new_student = Student() 175 self. importer.addEntry(175 self.processor.addEntry( 176 176 new_student, dict(), self.app) 177 177 assert len(self.app['students'].keys()) == 2 178 178 179 179 def test_checkConversion(self): 180 errs, inv_errs, conv_dict = self. importer.checkConversion(180 errs, inv_errs, conv_dict = self.processor.checkConversion( 181 181 dict(reg_number='1', reg_state='admitted')) 182 182 self.assertEqual(len(errs),0) 183 errs, inv_errs, conv_dict = self. importer.checkConversion(183 errs, inv_errs, conv_dict = self.processor.checkConversion( 184 184 dict(reg_number='1', reg_state='')) 185 185 self.assertEqual(len(errs),1) 186 186 self.assertTrue(('reg_state', 'no value provided') in errs) 187 errs, inv_errs, conv_dict = self. importer.checkConversion(187 errs, inv_errs, conv_dict = self.processor.checkConversion( 188 188 dict(reg_number='1', reg_state='nonsense')) 189 189 self.assertEqual(len(errs),1) … … 192 192 def test_delEntry(self): 193 193 assert self.student.student_id in self.app['students'].keys() 194 self. importer.delEntry(194 self.processor.delEntry( 195 195 dict(reg_number=self.student.reg_number), self.app) 196 196 assert self.student.student_id not in self.app['students'].keys() 197 197 198 198 def test_import(self): 199 num, num_warns, fin_file, fail_file = self. importer.doImport(199 num, num_warns, fin_file, fail_file = self.processor.doImport( 200 200 self.csv_file, STUDENT_HEADER_FIELDS) 201 201 self.assertEqual(num_warns,0) … … 205 205 206 206 def test_import_update(self): 207 num, num_warns, fin_file, fail_file = self. importer.doImport(207 num, num_warns, fin_file, fail_file = self.processor.doImport( 208 208 self.csv_file, STUDENT_HEADER_FIELDS) 209 209 shutil.rmtree(os.path.dirname(fin_file)) 210 num, num_warns, fin_file, fail_file = self. importer.doImport(210 num, num_warns, fin_file, fail_file = self.processor.doImport( 211 211 self.csv_file_update, STUDENT_HEADER_FIELDS_UPDATE, 'update') 212 212 self.assertEqual(num_warns,0) … … 214 214 215 215 def test_import_update2(self): 216 num, num_warns, fin_file, fail_file = self. importer.doImport(216 num, num_warns, fin_file, fail_file = self.processor.doImport( 217 217 self.csv_file, STUDENT_HEADER_FIELDS) 218 218 shutil.rmtree(os.path.dirname(fin_file)) 219 num, num_warns, fin_file, fail_file = self. importer.doImport(219 num, num_warns, fin_file, fail_file = self.processor.doImport( 220 220 self.csv_file_update2, STUDENT_HEADER_FIELDS_UPDATE2, 'update') 221 221 self.assertEqual(num_warns,0) … … 223 223 224 224 def test_import_remove(self): 225 num, num_warns, fin_file, fail_file = self. importer.doImport(225 num, num_warns, fin_file, fail_file = self.processor.doImport( 226 226 self.csv_file, STUDENT_HEADER_FIELDS) 227 227 shutil.rmtree(os.path.dirname(fin_file)) 228 num, num_warns, fin_file, fail_file = self. importer.doImport(228 num, num_warns, fin_file, fail_file = self.processor.doImport( 229 229 self.csv_file_update, STUDENT_HEADER_FIELDS_UPDATE, 'remove') 230 230 self.assertEqual(num_warns,0) … … 232 232 233 233 def test_import_migration_data(self): 234 num, num_warns, fin_file, fail_file = self. importer.doImport(234 num, num_warns, fin_file, fail_file = self.processor.doImport( 235 235 self.csv_file_migration, STUDENT_HEADER_FIELDS_MIGRATION) 236 236 self.assertEqual(num_warns,2) … … 251 251 252 252 253 class StudentStudyCourse ImporterTest(FunctionalTestCase):253 class StudentStudyCourseProcessorTest(FunctionalTestCase): 254 254 255 255 layer = FunctionalLayer 256 256 257 257 def setUp(self): 258 super(StudentStudyCourse ImporterTest, self).setUp()258 super(StudentStudyCourseProcessorTest, self).setUp() 259 259 self.dc_root = tempfile.mkdtemp() 260 260 self.workdir = tempfile.mkdtemp() … … 283 283 self.certificate) 284 284 285 self. importer = StudentStudyCourseProcessor()285 self.processor = StudentStudyCourseProcessor() 286 286 self.csv_file = os.path.join( 287 287 self.workdir, 'sample_studycourse_data.csv') … … 290 290 291 291 def tearDown(self): 292 super(StudentStudyCourse ImporterTest, self).tearDown()292 super(StudentStudyCourseProcessorTest, self).tearDown() 293 293 shutil.rmtree(self.workdir) 294 294 shutil.rmtree(self.dc_root) … … 298 298 def test_interface(self): 299 299 # Make sure we fulfill the interface contracts. 300 assert verifyObject(IBatchProcessor, self. importer) is True300 assert verifyObject(IBatchProcessor, self.processor) is True 301 301 assert verifyClass( 302 302 IBatchProcessor, StudentStudyCourseProcessor) is True 303 303 304 304 def test_entryExists(self): 305 assert self. importer.entryExists(305 assert self.processor.entryExists( 306 306 dict(reg_number='REG_NONE'), self.app) is False 307 assert self. importer.entryExists(307 assert self.processor.entryExists( 308 308 dict(reg_number='1'), self.app) is True 309 309 310 310 def test_getEntry(self): 311 student = self. importer.getEntry(311 student = self.processor.getEntry( 312 312 dict(reg_number='1'), self.app).__parent__ 313 313 self.assertEqual(student.reg_number,'1') 314 314 315 315 def test_checkConversion(self): 316 errs, inv_errs, conv_dict = self. importer.checkConversion(316 errs, inv_errs, conv_dict = self.processor.checkConversion( 317 317 dict(reg_number='1', certificate='CERT1', current_level='200')) 318 318 self.assertEqual(len(errs),0) 319 errs, inv_errs, conv_dict = self. importer.checkConversion(319 errs, inv_errs, conv_dict = self.processor.checkConversion( 320 320 dict(reg_number='1', certificate='CERT999')) 321 321 self.assertEqual(len(errs),1) 322 322 self.assertTrue(('certificate', u'Invalid value') in errs) 323 errs, inv_errs, conv_dict = self. importer.checkConversion(323 errs, inv_errs, conv_dict = self.processor.checkConversion( 324 324 dict(reg_number='1', certificate='CERT1', current_level='100')) 325 325 self.assertEqual(len(errs),1) 326 326 self.assertTrue(('current_level','not in range') in errs) 327 327 # If we import only current_level, no conversion checking is done. 328 errs, inv_errs, conv_dict = self. importer.checkConversion(328 errs, inv_errs, conv_dict = self.processor.checkConversion( 329 329 dict(reg_number='1', current_level='100')) 330 330 self.assertEqual(len(errs),0) 331 331 332 332 def test_import(self): 333 num, num_warns, fin_file, fail_file = self. importer.doImport(333 num, num_warns, fin_file, fail_file = self.processor.doImport( 334 334 self.csv_file, STUDYCOURSE_HEADER_FIELDS,'update') 335 335 self.assertEqual(num_warns,1) 336 studycourse = self. importer.getEntry(dict(reg_number='1'), self.app)336 studycourse = self.processor.getEntry(dict(reg_number='1'), self.app) 337 337 self.assertEqual(studycourse.certificate.code, u'CERT1') 338 338 shutil.rmtree(os.path.dirname(fin_file)) 339 339 340 class StudentStudyLevel ImporterTest(FunctionalTestCase):340 class StudentStudyLevelProcessorTest(FunctionalTestCase): 341 341 342 342 layer = FunctionalLayer 343 343 344 344 def setUp(self): 345 super(StudentStudyLevel ImporterTest, self).setUp()345 super(StudentStudyLevelProcessorTest, self).setUp() 346 346 self.dc_root = tempfile.mkdtemp() 347 347 self.workdir = tempfile.mkdtemp() … … 374 374 self.workdir, 'sample_studycourse_data.csv') 375 375 open(studycourse_file, 'wb').write(STUDYCOURSE_SAMPLE_DATA) 376 importer = StudentStudyCourseProcessor()377 num, num_warns, fin_file, fail_file = importer.doImport(376 processor = StudentStudyCourseProcessor() 377 num, num_warns, fin_file, fail_file = processor.doImport( 378 378 studycourse_file, STUDYCOURSE_HEADER_FIELDS,'update') 379 379 shutil.rmtree(os.path.dirname(fin_file)) 380 380 381 self. importer = StudentStudyLevelProcessor()381 self.processor = StudentStudyLevelProcessor() 382 382 self.csv_file = os.path.join( 383 383 self.workdir, 'sample_studylevel_data.csv') … … 385 385 386 386 def tearDown(self): 387 super(StudentStudyLevel ImporterTest, self).tearDown()387 super(StudentStudyLevelProcessorTest, self).tearDown() 388 388 shutil.rmtree(self.workdir) 389 389 shutil.rmtree(self.dc_root) … … 393 393 def test_interface(self): 394 394 # Make sure we fulfill the interface contracts. 395 assert verifyObject(IBatchProcessor, self. importer) is True395 assert verifyObject(IBatchProcessor, self.processor) is True 396 396 assert verifyClass( 397 397 IBatchProcessor, StudentStudyLevelProcessor) is True 398 398 399 399 def test_checkConversion(self): 400 errs, inv_errs, conv_dict = self. importer.checkConversion(400 errs, inv_errs, conv_dict = self.processor.checkConversion( 401 401 dict(reg_number='1', level='220')) 402 402 self.assertEqual(len(errs),0) 403 errs, inv_errs, conv_dict = self. importer.checkConversion(403 errs, inv_errs, conv_dict = self.processor.checkConversion( 404 404 dict(reg_number='1', level='900')) 405 405 self.assertEqual(len(errs),1) 406 406 self.assertTrue(('level','no valid integer') in errs) 407 errs, inv_errs, conv_dict = self. importer.checkConversion(407 errs, inv_errs, conv_dict = self.processor.checkConversion( 408 408 dict(reg_number='1', level='xyz')) 409 409 self.assertEqual(len(errs),1) … … 411 411 412 412 def test_import(self): 413 num, num_warns, fin_file, fail_file = self. importer.doImport(413 num, num_warns, fin_file, fail_file = self.processor.doImport( 414 414 self.csv_file, STUDYLEVEL_HEADER_FIELDS,'create') 415 415 self.assertEqual(num_warns,2) 416 assert self. importer.entryExists(416 assert self.processor.entryExists( 417 417 dict(reg_number='1', level='100'), self.app) is True 418 studylevel = self. importer.getEntry(418 studylevel = self.processor.getEntry( 419 419 dict(reg_number='1', level='100'), self.app) 420 420 self.assertEqual(studylevel.__parent__.certificate.code, u'CERT1') … … 425 425 426 426 427 class CourseTicket ImporterTest(FunctionalTestCase):427 class CourseTicketProcessorTest(FunctionalTestCase): 428 428 429 429 layer = FunctionalLayer 430 430 431 431 def setUp(self): 432 super(CourseTicket ImporterTest, self).setUp()432 super(CourseTicketProcessorTest, self).setUp() 433 433 self.dc_root = tempfile.mkdtemp() 434 434 self.workdir = tempfile.mkdtemp() … … 470 470 self.workdir, 'sample_studycourse_data.csv') 471 471 open(studycourse_file, 'wb').write(STUDYCOURSE_SAMPLE_DATA) 472 importer = StudentStudyCourseProcessor()473 num, num_warns, fin_file, fail_file = importer.doImport(472 processor = StudentStudyCourseProcessor() 473 num, num_warns, fin_file, fail_file = processor.doImport( 474 474 studycourse_file, STUDYCOURSE_HEADER_FIELDS,'update') 475 475 shutil.rmtree(os.path.dirname(fin_file)) 476 476 477 477 # Import study levels 478 importer = StudentStudyLevelProcessor()478 processor = StudentStudyLevelProcessor() 479 479 studylevel_file = os.path.join( 480 480 self.workdir, 'sample_studylevel_data.csv') 481 481 open(studylevel_file, 'wb').write(STUDYLEVEL_SAMPLE_DATA) 482 num, num_warns, fin_file, fail_file = importer.doImport(482 num, num_warns, fin_file, fail_file = processor.doImport( 483 483 studylevel_file, STUDYLEVEL_HEADER_FIELDS,'create') 484 484 shutil.rmtree(os.path.dirname(fin_file)) 485 485 486 self. importer = CourseTicketProcessor()486 self.processor = CourseTicketProcessor() 487 487 self.csv_file = os.path.join( 488 488 self.workdir, 'sample_courseticket_data.csv') … … 490 490 491 491 def tearDown(self): 492 super(CourseTicket ImporterTest, self).tearDown()492 super(CourseTicketProcessorTest, self).tearDown() 493 493 shutil.rmtree(self.workdir) 494 494 shutil.rmtree(self.dc_root) … … 498 498 def test_interface(self): 499 499 # Make sure we fulfill the interface contracts. 500 assert verifyObject(IBatchProcessor, self. importer) is True500 assert verifyObject(IBatchProcessor, self.processor) is True 501 501 assert verifyClass( 502 502 IBatchProcessor, CourseTicketProcessor) is True 503 503 504 504 def test_checkConversion(self): 505 errs, inv_errs, conv_dict = self. importer.checkConversion(505 errs, inv_errs, conv_dict = self.processor.checkConversion( 506 506 dict(reg_number='1', code='COURSE1', level='220')) 507 507 self.assertEqual(len(errs),0) 508 errs, inv_errs, conv_dict = self. importer.checkConversion(508 errs, inv_errs, conv_dict = self.processor.checkConversion( 509 509 dict(reg_number='1', code='COURSE2', level='220')) 510 510 self.assertEqual(len(errs),1) … … 513 513 def test_import(self): 514 514 515 num, num_warns, fin_file, fail_file = self. importer.doImport(515 num, num_warns, fin_file, fail_file = self.processor.doImport( 516 516 self.csv_file, COURSETICKET_HEADER_FIELDS,'create') 517 517 518 518 self.assertEqual(num_warns,2) 519 assert self. importer.entryExists(519 assert self.processor.entryExists( 520 520 dict(reg_number='1', level='100', code='COURSE1'), self.app) is True 521 courseticket = self. importer.getEntry(521 courseticket = self.processor.getEntry( 522 522 dict(reg_number='1', level='100', code='COURSE1'), self.app) 523 523 self.assertEqual(courseticket.__parent__.__parent__.certificate.code, u'CERT1') … … 533 533 shutil.rmtree(os.path.dirname(fin_file)) 534 534 535 class Payment ImporterTest(FunctionalTestCase):535 class PaymentProcessorTest(FunctionalTestCase): 536 536 537 537 layer = FunctionalLayer 538 538 539 539 def setUp(self): 540 super(Payment ImporterTest, self).setUp()540 super(PaymentProcessorTest, self).setUp() 541 541 self.dc_root = tempfile.mkdtemp() 542 542 self.workdir = tempfile.mkdtemp() … … 566 566 shutil.rmtree(os.path.dirname(fin_file)) 567 567 568 self. importer = StudentOnlinePaymentProcessor()568 self.processor = StudentOnlinePaymentProcessor() 569 569 self.csv_file = os.path.join( 570 570 self.workdir, 'sample_payment_data.csv') … … 572 572 573 573 def tearDown(self): 574 super(Payment ImporterTest, self).tearDown()574 super(PaymentProcessorTest, self).tearDown() 575 575 shutil.rmtree(self.workdir) 576 576 shutil.rmtree(self.dc_root) … … 580 580 def test_interface(self): 581 581 # Make sure we fulfill the interface contracts. 582 assert verifyObject(IBatchProcessor, self. importer) is True582 assert verifyObject(IBatchProcessor, self.processor) is True 583 583 assert verifyClass( 584 584 IBatchProcessor, StudentOnlinePaymentProcessor) is True 585 585 586 586 def test_getEntry(self): 587 assert self. importer.getEntry(587 assert self.processor.getEntry( 588 588 dict(student_id='ID_NONE', p_id='nonsense'), self.app) is None 589 assert self. importer.getEntry(589 assert self.processor.getEntry( 590 590 dict(student_id=self.student.student_id, p_id='p123'), 591 591 self.app) is self.student['payments']['p123'] 592 assert self. importer.getEntry(592 assert self.processor.getEntry( 593 593 dict(student_id=self.student.student_id, p_id='XXXXXX123'), 594 594 self.app) is self.student['payments']['p123'] … … 598 598 payment1 = createObject(u'waeup.StudentOnlinePayment') 599 599 payment1.p_id = 'p234' 600 self. importer.addEntry(600 self.processor.addEntry( 601 601 payment1, dict(student_id=self.student.student_id, p_id='p234'), 602 602 self.app) … … 606 606 payment1.p_id = 'nonsense' 607 607 # payment1.p_id will be replaced if p_id doesn't start with 'p' 608 self. importer.addEntry(608 self.processor.addEntry( 609 609 payment2, dict(student_id=self.student.student_id, p_id='XXXXXX456'), 610 610 self.app) … … 613 613 614 614 def test_checkConversion(self): 615 errs, inv_errs, conv_dict = self. importer.checkConversion(615 errs, inv_errs, conv_dict = self.processor.checkConversion( 616 616 dict(reg_number='1', p_id='3816951266236341955')) 617 617 self.assertEqual(len(errs),0) 618 errs, inv_errs, conv_dict = self. importer.checkConversion(618 errs, inv_errs, conv_dict = self.processor.checkConversion( 619 619 dict(reg_number='1', p_id='p1266236341955')) 620 620 self.assertEqual(len(errs),0) 621 errs, inv_errs, conv_dict = self. importer.checkConversion(621 errs, inv_errs, conv_dict = self.processor.checkConversion( 622 622 dict(reg_number='1', p_id='nonsense')) 623 623 self.assertEqual(len(errs),1) 624 624 timestamp = "%d" % int(time()*1000) 625 625 p_id = "p%s" % timestamp 626 errs, inv_errs, conv_dict = self. importer.checkConversion(626 errs, inv_errs, conv_dict = self.processor.checkConversion( 627 627 dict(reg_number='1', p_id=p_id)) 628 628 self.assertEqual(len(errs),0) 629 629 630 630 def test_import(self): 631 num, num_warns, fin_file, fail_file = self. importer.doImport(631 num, num_warns, fin_file, fail_file = self.processor.doImport( 632 632 self.csv_file, PAYMENT_HEADER_FIELDS,'create') 633 633 self.assertEqual(num_warns,0) 634 payment = self. importer.getEntry(dict(reg_number='1',634 payment = self.processor.getEntry(dict(reg_number='1', 635 635 p_id='p1290797973744'), self.app) 636 636 self.assertEqual(payment.p_id, 'p1290797973744') … … 642 642 suite = unittest.TestSuite() 643 643 for testcase in [ 644 Student ImporterTest,StudentStudyCourseImporterTest,645 StudentStudyLevel ImporterTest,CourseTicketImporterTest,646 Payment ImporterTest,]:644 StudentProcessorTest,StudentStudyCourseProcessorTest, 645 StudentStudyLevelProcessorTest,CourseTicketProcessorTest, 646 PaymentProcessorTest,]: 647 647 suite.addTest(unittest.TestLoader().loadTestsFromTestCase( 648 648 testcase -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r7887 r7933 743 743 importerselect = self.browser.getControl(name='importer') 744 744 modeselect = self.browser.getControl(name='mode') 745 importerselect.getControl('Student Importer').selected = True745 importerselect.getControl('Student Processor').selected = True 746 746 modeselect.getControl(value='create').selected = True 747 747 self.browser.getControl('Proceed to step 3').click() … … 770 770 modeselect = self.browser.getControl(name='mode') 771 771 importerselect.getControl( 772 'StudentStudyCourse Importer (update only)').selected = True772 'StudentStudyCourse Processor (update only)').selected = True 773 773 modeselect.getControl(value='create').selected = True 774 774 self.browser.getControl('Proceed to step 3').click() -
main/waeup.kofa/trunk/src/waeup/kofa/university/batching.py
r7811 r7933 38 38 grok.provides(IBatchProcessor) 39 39 grok.context(Interface) 40 util_name = 'faculty importer'41 grok.name(util_name) 42 43 name = u'Faculty Importer'40 util_name = 'facultyprocessor' 41 grok.name(util_name) 42 43 name = u'Faculty Processor' 44 44 iface = IFaculty 45 45 … … 80 80 grok.provides(IBatchProcessor) 81 81 grok.context(Interface) 82 util_name = 'department importer'83 grok.name(util_name) 84 85 name = u'Department Importer'82 util_name = 'departmentprocessor' 83 grok.name(util_name) 84 85 name = u'Department Processor' 86 86 iface = IDepartment 87 87 … … 127 127 grok.provides(IBatchProcessor) 128 128 grok.context(Interface) 129 util_name = 'course importer'130 grok.name(util_name) 131 132 name = u'Course Importer'129 util_name = 'courseprocessor' 130 grok.name(util_name) 131 132 name = u'Course Processor' 133 133 iface = ICourse 134 134 … … 178 178 grok.provides(IBatchProcessor) 179 179 grok.context(Interface) 180 util_name = 'certificate importer'181 grok.name(util_name) 182 183 name = u'Certificate Importer'180 util_name = 'certificateprocessor' 181 grok.name(util_name) 182 183 name = u'Certificate Processor' 184 184 iface = ICertificate 185 185 … … 229 229 grok.provides(IBatchProcessor) 230 230 grok.context(Interface) 231 util_name = 'certificatecourse importer'232 grok.name(util_name) 233 234 name = u'CertificateCourse Importer'231 util_name = 'certificatecourseprocessor' 232 grok.name(util_name) 233 234 name = u'CertificateCourse Processor' 235 235 iface = ICertificateCourse 236 236 -
main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py
r7907 r7933 44 44 45 45 # Name used in pages and forms... 46 name = u'Non-registered base importer'46 name = u'Non-registered base processor' 47 47 48 48 # Internal name... 49 util_name = 'base importer'49 util_name = 'baseprocessor' 50 50 51 51 # Items for this processor need an interface with zope.schema fields. -
main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.txt
r7811 r7933 10 10 mass-remove, or mass-update data. 11 11 12 So you can feed CSV files to importers orprocessors, that are part of12 So you can feed CSV files to processors, that are part of 13 13 the batch-processing mechanism. 14 14 15 Importers/Processors16 ---------- ----------15 Processors 16 ---------- 17 17 18 18 Each CSV file processor -
main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py
r7819 r7933 152 152 153 153 In :mod:`waeup.kofa` we use factories extensively for 154 batching. While processing a batch some importerlooks up a154 batching. While processing a batch some processors looks up a 155 155 factory to create real-world instances that then get filled with 156 156 data from imported CSV files. … … 192 192 True 193 193 194 After grokking we (and importers) can create objects without194 After grokking we (and processors) can create objects without 195 195 knowing about the location of the real class definition, just by 196 196 the factory name:
Note: See TracChangeset for help on using the changeset viewer.