Ignore:
Timestamp:
18 Dec 2014, 15:47:12 (10 years ago)
Author:
Henrik Bettermann
Message:

Adjust tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py

    r12256 r12259  
    139139        contract = createObject('waeup.SampleContract')
    140140        contract.title = u'My Contract'
     141        contract.contract_id = u'CON1'
    141142        contract.product_object = self.product
    142143        contract.document_object = self.document
     
    436437            dict(customer_id='ID_NONE', contract_id='nonsense'), self.app) is None
    437438        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']
    440441
    441442    def test_delEntry(self):
    442443        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']
    445446        self.assertEqual(len(self.customer['contracts'].keys()),1)
    446447        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'),
    448449            self.app)
    449450        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'),
    451452            self.app) is None
    452453        self.assertEqual(len(self.customer['contracts'].keys()),0)
    453454
    454455    def test_addEntry(self):
    455         self.assertEqual(self.app._curr_con_id, 102)
    456456        self.assertEqual(len(self.customer['contracts'].keys()),1)
    457457        contract1 = createObject(u'waeup.SampleContract')
    458         contract1.contract_id = 'c234'
     458        contract1.contract_id = u'CON2'
    459459        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'),
    461461            self.app)
    462462        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')
    466464
    467465    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',
    471468                 document_object='DOC1', product_object='SAM'))
    472469        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'))
    475475        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 changed
    480         self.assertEqual(self.app._curr_con_id, 102)
    481476
    482477    def test_import(self):
     
    487482        fail_file = open(fail_file).read()
    488483        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            )
    497489        contract = self.processor.getEntry(dict(reg_number='1',
    498490            contract_id='c3'), self.app)
     
    506498        logcontent = open(self.logfile).read()
    507499        # 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]
    508503        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
    512507            in logcontent)
    513508
     
    521516        num, num_warns, fin_file, fail_file = self.processor.doImport(
    522517            self.csv_file, CONTRACT_HEADER_FIELDS,'update')
    523         # There are one record without contract_id, one duplicate and two
     518        # There are one record without contract_id and two
    524519        # records with wrong object identifier.
    525         self.assertEqual(num_warns,4)
     520        self.assertEqual(num_warns,3)
    526521        shutil.rmtree(os.path.dirname(fin_file))
    527522
Note: See TracChangeset for help on using the changeset viewer.