Changeset 12005 for main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Timestamp:
- 20 Nov 2014, 05:40:52 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/batching.py
r12004 r12005 40 40 from waeup.ikoba.interfaces import IIkobaUtils 41 41 from waeup.ikoba.interfaces import MessageFactory as _ 42 from waeup.ikoba.documents.utils import generate_document_id 42 43 from waeup.ikoba.customers.interfaces import ( 43 44 ICustomer, ICustomerUpdateByRegNo, … … 440 441 document_id = row.get('document_id', None) 441 442 if not document_id: 442 timestamp = ("%d" % int(time()*10000))[1:] 443 document_id = "d%s" % timestamp 443 document_id = generate_document_id() 444 444 conv_dict['document_id'] = document_id 445 445 return errs, inv_errs, conv_dict 446 if not document_id.startswith('d') or len(document_id) != 14: 446 # document_id must not exist. 447 if mode == 'create': 448 cat = queryUtility(ICatalog, name='documents_catalog') 449 results = list( 450 cat.searchResults(document_id=(document_id, document_id))) 451 if results: 452 errs.append(('document_id','id exists')) 453 if not document_id.startswith('d'): 447 454 errs.append(('document_id','invalid format')) 448 455 return errs, inv_errs, conv_dict -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/customer.py
r11997 r12005 1 ## $Id : customer.py 11604 2014-04-29 07:31:54Z henrik$1 ## $Id$ 2 2 ## 3 3 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/sample_document_data.csv
r12004 r12005 1 1 document_id,reg_number,title 2 d 1266236341953,1,My first doc3 d 1266236341954,2,My second doc4 d 1266236341955,3,My third doc2 d3,1,My first doc 3 d4,2,My second doc 4 d5,3,My third doc 5 5 ,1,My 4th doc 6 d5,2,My stolen doc -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py
r12004 r12005 328 328 num, num_warns, fin_file, fail_file = self.processor.doImport( 329 329 self.csv_file, DOCUMENT_HEADER_FIELDS,'create') 330 self.assertEqual(num_warns,0) 330 self.assertEqual(num_warns,1) 331 # document_id must be unique 332 fail_file = open(fail_file).read() 333 self.assertEqual(fail_file, 334 'reg_number,document_id,title,--ERRORS--\r\n' 335 '2,d5,My stolen doc,document_id: id exists\r\n') 331 336 document = self.processor.getEntry(dict(reg_number='1', 332 document_id='d 1266236341953'), self.app)337 document_id='d3'), self.app) 333 338 self.assertEqual( 334 self.app['customers']['X666666']['documents']['d 1266236341953'],339 self.app['customers']['X666666']['documents']['d3'], 335 340 document) 336 self.assertEqual(document.document_id, 'd 1266236341953')341 self.assertEqual(document.document_id, 'd3') 337 342 document = self.processor.getEntry(dict(reg_number='3', 338 document_id='d 1266236341955'), self.app)343 document_id='d5'), self.app) 339 344 shutil.rmtree(os.path.dirname(fin_file)) 340 345 logcontent = open(self.logfile).read() … … 343 348 'INFO - system - CustomerDocument Processor - ' 344 349 'sample_document_data - X666666 - updated: ' 345 'document_id=d 1266236341953, title=My first doc'350 'document_id=d3, title=My first doc' 346 351 in logcontent) 347 352 … … 355 360 num, num_warns, fin_file, fail_file = self.processor.doImport( 356 361 self.csv_file, DOCUMENT_HEADER_FIELDS,'update') 357 self.assertEqual(num_warns,1) # There is one record without document_id 362 # There is one record without document_id and one duplicate 363 self.assertEqual(num_warns,2) 358 364 shutil.rmtree(os.path.dirname(fin_file)) 359 365 … … 367 373 num, num_warns, fin_file, fail_file = self.processor.doImport( 368 374 self.csv_file, DOCUMENT_HEADER_FIELDS,'remove') 369 self.assertEqual(num_warns,1) # There is one record without document_id 375 # There is one record without document_id and one duplicate 376 self.assertEqual(num_warns,2) 370 377 shutil.rmtree(os.path.dirname(fin_file)) 371 378 logcontent = open(self.logfile).read() 372 379 self.assertTrue( 373 'INFO - system - K1000001 - Document removed: d 1266236341955'380 'INFO - system - K1000001 - Document removed: d5' 374 381 in logcontent)
Note: See TracChangeset for help on using the changeset viewer.