- Timestamp:
- 18 Dec 2014, 15:47:12 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py
r12256 r12259 139 139 contract = createObject('waeup.SampleContract') 140 140 contract.title = u'My Contract' 141 contract.contract_id = u'CON1' 141 142 contract.product_object = self.product 142 143 contract.document_object = self.document … … 436 437 dict(customer_id='ID_NONE', contract_id='nonsense'), self.app) is None 437 438 assert self.processor.getEntry( 438 dict(customer_id=self.customer.customer_id, contract_id=' c101'),439 self.app) is self.customer['contracts'][' c101']439 dict(customer_id=self.customer.customer_id, contract_id='CON1'), 440 self.app) is self.customer['contracts']['CON1'] 440 441 441 442 def test_delEntry(self): 442 443 assert self.processor.getEntry( 443 dict(customer_id=self.customer.customer_id, contract_id=' c101'),444 self.app) is self.customer['contracts'][' c101']444 dict(customer_id=self.customer.customer_id, contract_id='CON1'), 445 self.app) is self.customer['contracts']['CON1'] 445 446 self.assertEqual(len(self.customer['contracts'].keys()),1) 446 447 self.processor.delEntry( 447 dict(customer_id=self.customer.customer_id, contract_id=' c101'),448 dict(customer_id=self.customer.customer_id, contract_id='CON1'), 448 449 self.app) 449 450 assert self.processor.getEntry( 450 dict(customer_id=self.customer.customer_id, contract_id=' c101'),451 dict(customer_id=self.customer.customer_id, contract_id='CON1'), 451 452 self.app) is None 452 453 self.assertEqual(len(self.customer['contracts'].keys()),0) 453 454 454 455 def test_addEntry(self): 455 self.assertEqual(self.app._curr_con_id, 102)456 456 self.assertEqual(len(self.customer['contracts'].keys()),1) 457 457 contract1 = createObject(u'waeup.SampleContract') 458 contract1.contract_id = 'c234'458 contract1.contract_id = u'CON2' 459 459 self.processor.addEntry( 460 contract1, dict(customer_id=self.customer.customer_id, contract_id=' c234'),460 contract1, dict(customer_id=self.customer.customer_id, contract_id='CON2'), 461 461 self.app) 462 462 self.assertEqual(len(self.customer['contracts'].keys()),2) 463 self.assertEqual(self.customer['contracts']['c234'].contract_id, 'c234') 464 # _curr_con_id hasn't changed 465 self.assertEqual(self.app._curr_con_id, 102) 463 self.assertEqual(self.customer['contracts']['CON2'].contract_id, 'CON2') 466 464 467 465 def test_checkConversion(self): 468 self.assertEqual(self.app._curr_con_id, 102) 469 errs, inv_errs, conv_dict = self.processor.checkConversion( 470 dict(contract_id='c126', class_name='SampleContract', 466 errs, inv_errs, conv_dict = self.processor.checkConversion( 467 dict(contract_id='CON3', class_name='SampleContract', 471 468 document_object='DOC1', product_object='SAM')) 472 469 self.assertEqual(len(errs),0) 473 errs, inv_errs, conv_dict = self.processor.checkConversion( 474 dict(contract_id='nonsense', class_name='SampleContract')) 470 #errs, inv_errs, conv_dict = self.processor.checkConversion( 471 # dict(contract_id='id with spaces', class_name='SampleContract')) 472 #self.assertEqual(len(errs),1) 473 errs, inv_errs, conv_dict = self.processor.checkConversion( 474 dict(contract_id='CON3', class_name='WrongContract')) 475 475 self.assertEqual(len(errs),1) 476 errs, inv_errs, conv_dict = self.processor.checkConversion(477 dict(contract_id='c127', class_name='WrongContract'))478 self.assertEqual(len(errs),1)479 # _curr_con_id hasn't changed480 self.assertEqual(self.app._curr_con_id, 102)481 476 482 477 def test_import(self): … … 487 482 fail_file = open(fail_file).read() 488 483 self.assertEqual(fail_file, 489 'reg_number,contract_id,title,class_name,product_object,' 490 'document_object,--ERRORS--\r\n' 491 '2,c5,My stolen contract,SampleContract,SAM,DOC1,' 492 'contract_id: id exists\r\n' 493 '3,c6,My 5th contract,SampleContract,SAM,NONEXISTENT,' 494 'document_object: Invalid value\r\n' 495 '3,c7,My sixt contract,SampleContract,NONEXISTENT,DOC1,' 496 'product_object: Invalid value\r\n') 484 'reg_number,contract_id,title,class_name,product_object,document_object,--ERRORS--\r\n' 485 '2,c5,My stolen contract,SampleContract,SAM,DOC1,This object already exists. Skipping.\r\n' 486 '3,c6,My 5th contract,SampleContract,SAM,NONEXISTENT,document_object: Invalid value\r\n' 487 '3,c7,My sixt contract,SampleContract,NONEXISTENT,DOC1,product_object: Invalid value\r\n' 488 ) 497 489 contract = self.processor.getEntry(dict(reg_number='1', 498 490 contract_id='c3'), self.app) … … 506 498 logcontent = open(self.logfile).read() 507 499 # Logging message from updateEntry 500 # Fetch uuid 501 conid = [i for i in self.app['customers']['X666666']['contracts'].keys() 502 if len(i) > 10][0] 508 503 self.assertTrue( 509 'INFO - system - Contract Processor - '510 ' sample_contract_data - X666666 - updated:'511 ' contract_id=c3, title=My first contract'504 'INFO - system - Contract Processor - sample_contract_data - ' 505 'X666666 - %s - updated: title=My 4th contract, ' 506 'product_object=SAM, document_object=DOC1' % conid 512 507 in logcontent) 513 508 … … 521 516 num, num_warns, fin_file, fail_file = self.processor.doImport( 522 517 self.csv_file, CONTRACT_HEADER_FIELDS,'update') 523 # There are one record without contract_id , one duplicateand two518 # There are one record without contract_id and two 524 519 # records with wrong object identifier. 525 self.assertEqual(num_warns, 4)520 self.assertEqual(num_warns,3) 526 521 shutil.rmtree(os.path.dirname(fin_file)) 527 522
Note: See TracChangeset for help on using the changeset viewer.