Changeset 12281 for main/waeup.ikoba
- Timestamp:
- 21 Dec 2014, 10:35:54 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/batching.py
r12258 r12281 43 43 from waeup.ikoba.customers.interfaces import ( 44 44 ICustomer, ICustomerUpdateByRegNo, 45 ICustomer Document, IContract, ISampleContract)45 ICustomerSampleDocument, ISampleContract) 46 46 from waeup.ikoba.customers.workflow import ( 47 47 IMPORTABLE_REGISTRATION_STATES, IMPORTABLE_REGISTRATION_TRANSITIONS) … … 366 366 return result 367 367 368 class CustomerDocumentProcessor(CustomerProcessorBase): 369 """A batch processor for ICustomerDocument objects. 368 class CustomerDocumentProcessorBase(CustomerProcessorBase): 369 """A batch processor for customer documents. 370 371 This is a baseclass. 370 372 """ 371 373 grok.implements(IBatchProcessor) 372 374 grok.provides(IBatchProcessor) 373 375 grok.context(Interface) 374 util_name = 'customerdocumentprocessor' 375 grok.name(util_name) 376 377 name = _('CustomerDocument Processor') 378 iface = ICustomerDocument 379 factory_name = 'waeup.CustomerSampleDocument' 376 377 grok.baseclass() 378 379 util_name = None 380 name = None 381 iface = None 382 factory_name = None 380 383 381 384 location_fields = [] … … 384 387 385 388 def checkHeaders(self, headerfields, mode='ignore'): 386 super(CustomerDocumentProcessor , self).checkHeaders(headerfields)389 super(CustomerDocumentProcessorBase, self).checkHeaders(headerfields) 387 390 if mode in ('update', 'remove') and not 'document_id' in headerfields: 388 391 raise FatalCSVError( … … 412 415 if 'document_id' in row and row['document_id'] in (None, IGNORE_MARKER): 413 416 row.pop('document_id') 414 items_changed = super(CustomerDocumentProcessor , self).updateEntry(417 items_changed = super(CustomerDocumentProcessorBase, self).updateEntry( 415 418 obj, row, site, filename) 416 419 customer = self.getParent(row, site).__parent__ … … 440 443 """ 441 444 errs, inv_errs, conv_dict = super( 442 CustomerDocumentProcessor , self).checkConversion(row, mode=mode)445 CustomerDocumentProcessorBase, self).checkConversion(row, mode=mode) 443 446 # We need to check if the class_name corresponds with the 444 447 # processor chosen. This is to avoid accidentally wrong imports. … … 450 453 451 454 452 class ContractProcessor(CustomerProcessorBase): 453 """A batch processor for IContract objects. 455 class CustomerSampleDocumentProcessor(CustomerDocumentProcessorBase): 456 """A batch processor for ICustomerSampleDocument objects. 457 """ 458 util_name = 'customersampledocumentprocessor' 459 grok.name(util_name) 460 461 name = _('Customer Sample Document Processor') 462 iface = ICustomerSampleDocument 463 factory_name = 'waeup.CustomerSampleDocument' 464 465 466 class ContractProcessorBase(CustomerProcessorBase): 467 """A batch processor for contracts. 468 469 This is a baseclass. 454 470 """ 455 471 grok.implements(IBatchProcessor) 456 472 grok.provides(IBatchProcessor) 457 473 grok.context(Interface) 458 util_name = 'contractprocessor' 459 grok.name(util_name) 460 461 name = _('Contract Processor') 462 iface = ISampleContract 463 factory_name = 'waeup.SampleContract' 474 475 grok.baseclass() 476 477 util_name = None 478 name = None 479 iface = None 480 factory_name = None 464 481 465 482 location_fields = [] … … 468 485 469 486 def checkHeaders(self, headerfields, mode='ignore'): 470 super(ContractProcessor , self).checkHeaders(headerfields)487 super(ContractProcessorBase, self).checkHeaders(headerfields) 471 488 if mode in ('update', 'remove') and not 'contract_id' in headerfields: 472 489 raise FatalCSVError( … … 499 516 if 'contract_id' in row and row['contract_id'] in (None, IGNORE_MARKER): 500 517 row.pop('contract_id') 501 items_changed = super(ContractProcessor , self).updateEntry(518 items_changed = super(ContractProcessorBase, self).updateEntry( 502 519 obj, row, site, filename) 503 520 customer = self.getParent(row, site).__parent__ … … 527 544 """ 528 545 errs, inv_errs, conv_dict = super( 529 ContractProcessor , self).checkConversion(row, mode=mode)546 ContractProcessorBase, self).checkConversion(row, mode=mode) 530 547 # We need to check if the class_name corresponds with the 531 548 # processor chosen. This is to avoid accidentally wrong imports. … … 535 552 errs.append(('class_name','wrong processor')) 536 553 return errs, inv_errs, conv_dict 554 555 556 class SampleContractProcessor(ContractProcessorBase): 557 """A batch processor for ISampleContract objects. 558 """ 559 util_name = 'samplecontractprocessor' 560 grok.name(util_name) 561 562 name = _('Sample Contract Processor') 563 iface = ISampleContract 564 factory_name = 'waeup.SampleContract' -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py
r12261 r12281 37 37 IBatchProcessor, FatalCSVError, IUserAccount, VERIFIED) 38 38 from waeup.ikoba.customers.batching import ( 39 CustomerProcessor, Customer DocumentProcessor,ContractProcessor)39 CustomerProcessor, CustomerSampleDocumentProcessor, SampleContractProcessor) 40 40 from waeup.ikoba.customers.customer import Customer 41 41 from waeup.ikoba.customers.documents import CustomerSampleDocument … … 274 274 shutil.rmtree(os.path.dirname(fin_file)) 275 275 276 class Customer DocumentProcessorTest(CustomerImportExportSetup):276 class CustomerSampleDocumentProcessorTest(CustomerImportExportSetup): 277 277 278 278 def setUp(self): 279 super(Customer DocumentProcessorTest, self).setUp()279 super(CustomerSampleDocumentProcessorTest, self).setUp() 280 280 281 281 customer = Customer() … … 292 292 shutil.rmtree(os.path.dirname(fin_file)) 293 293 294 self.processor = Customer DocumentProcessor()294 self.processor = CustomerSampleDocumentProcessor() 295 295 self.csv_file = os.path.join( 296 296 self.workdir, 'sample_document_data.csv') … … 301 301 assert verifyObject(IBatchProcessor, self.processor) is True 302 302 assert verifyClass( 303 IBatchProcessor, Customer DocumentProcessor) is True303 IBatchProcessor, CustomerSampleDocumentProcessor) is True 304 304 305 305 def test_getEntry(self): … … 369 369 # Logging message from updateEntry 370 370 self.assertTrue( 371 'INFO - system - Customer Document Processor - '371 'INFO - system - Customer Sample Document Processor - ' 372 372 'sample_document_data - X666666 - %s - updated: title=My 4th doc' 373 373 % docid in logcontent) … … 404 404 405 405 406 class ContractProcessorTest(CustomerImportExportSetup):406 class SampleContractProcessorTest(CustomerImportExportSetup): 407 407 408 408 def setUp(self): 409 super( ContractProcessorTest, self).setUp()409 super(SampleContractProcessorTest, self).setUp() 410 410 411 411 customer = Customer() … … 422 422 shutil.rmtree(os.path.dirname(fin_file)) 423 423 424 self.processor = ContractProcessor()424 self.processor = SampleContractProcessor() 425 425 self.csv_file = os.path.join( 426 426 self.workdir, 'sample_contract_data.csv') … … 431 431 assert verifyObject(IBatchProcessor, self.processor) is True 432 432 assert verifyClass( 433 IBatchProcessor, ContractProcessor) is True433 IBatchProcessor, SampleContractProcessor) is True 434 434 435 435 def test_getEntry(self): … … 502 502 if len(i) > 10][0] 503 503 self.assertTrue( 504 'INFO - system - Contract Processor - sample_contract_data - '504 'INFO - system - Sample Contract Processor - sample_contract_data - ' 505 505 'X666666 - %s - updated: title=My 4th contract, ' 506 506 'product_object=SAM, document_object=DOC1' % conid
Note: See TracChangeset for help on using the changeset viewer.