Ignore:
Timestamp:
20 Nov 2014, 05:40:52 (10 years ago)
Author:
Henrik Bettermann
Message:

Implement document_id generator. Ensure that document_ids remain unique during import.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/sample_document_data.csv

    r12004 r12005  
    11document_id,reg_number,title
    2 d1266236341953,1,My first doc
    3 d1266236341954,2,My second doc
    4 d1266236341955,3,My third doc
     2d3,1,My first doc
     3d4,2,My second doc
     4d5,3,My third doc
    55,1,My 4th doc
     6d5,2,My stolen doc
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py

    r12004 r12005  
    328328        num, num_warns, fin_file, fail_file = self.processor.doImport(
    329329            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')
    331336        document = self.processor.getEntry(dict(reg_number='1',
    332             document_id='d1266236341953'), self.app)
     337            document_id='d3'), self.app)
    333338        self.assertEqual(
    334             self.app['customers']['X666666']['documents']['d1266236341953'],
     339            self.app['customers']['X666666']['documents']['d3'],
    335340            document)
    336         self.assertEqual(document.document_id, 'd1266236341953')
     341        self.assertEqual(document.document_id, 'd3')
    337342        document = self.processor.getEntry(dict(reg_number='3',
    338             document_id='d1266236341955'), self.app)
     343            document_id='d5'), self.app)
    339344        shutil.rmtree(os.path.dirname(fin_file))
    340345        logcontent = open(self.logfile).read()
     
    343348            'INFO - system - CustomerDocument Processor - '
    344349            'sample_document_data - X666666 - updated: '
    345             'document_id=d1266236341953, title=My first doc'
     350            'document_id=d3, title=My first doc'
    346351            in logcontent)
    347352
     
    355360        num, num_warns, fin_file, fail_file = self.processor.doImport(
    356361            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)
    358364        shutil.rmtree(os.path.dirname(fin_file))
    359365
     
    367373        num, num_warns, fin_file, fail_file = self.processor.doImport(
    368374            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)
    370377        shutil.rmtree(os.path.dirname(fin_file))
    371378        logcontent = open(self.logfile).read()
    372379        self.assertTrue(
    373             'INFO - system - K1000001 - Document removed: d1266236341955'
     380            'INFO - system - K1000001 - Document removed: d5'
    374381            in logcontent)
Note: See TracChangeset for help on using the changeset viewer.