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

Adjust tests.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests
Files:
5 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
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12256 r12259  
    124124        self.contract = createObject('waeup.SampleContract')
    125125        self.contract.title = u'My first contract'
     126        self.contract.contract_id = u'CON1'
    126127        self.customer['contracts'].addContract(self.contract)
    127128
     
    11611162        self.browser.getControl("Add contract").click()
    11621163        self.assertTrue('Sample Contract added.' in self.browser.contents)
    1163         contract = self.customer['contracts']['c102']
     1164        conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0]
     1165        contract = self.customer['contracts'][conid]
    11641166
    11651167        # Contract can be edited
    1166         self.browser.getLink("c102").click()
     1168        self.browser.getLink(conid).click()
    11671169        self.browser.getLink("Manage").click()
    11681170        self.browser.getControl(name="form.product_object").value = ['SAM']
     
    11711173        self.assertTrue('Form has been saved.' in self.browser.contents)
    11721174        self.browser.getLink("View").click()
    1173         self.assertEqual(self.browser.url, self.contracts_path + '/c102/index')
     1175        self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid)
    11741176
    11751177        # Transitions can be performed
     
    11941196        logcontent = open(logfile).read()
    11951197        self.assertTrue(
    1196             'INFO - zope.mgr - K1000000 - c102 - Contract created'
     1198            'INFO - zope.mgr - K1000000 - %s - Contract created' % conid
    11971199            in logcontent)
    11981200        self.assertTrue(
     
    12021204        self.assertTrue(
    12031205            'INFO - zope.mgr - customers.browser.ContractManageFormPage '
    1204             '- K1000000 - c102 - saved: title'
     1206            '- K1000000 - %s - saved: title' % conid
    12051207            in logcontent)
    12061208        self.assertTrue(
    1207             'INFO - zope.mgr - K1000000 - c102 - Submitted for approval'
     1209            'INFO - zope.mgr - K1000000 - %s - Submitted for approval' % conid
    12081210            in logcontent)
    12091211        self.assertTrue(
    1210             'INFO - zope.mgr - K1000000 - c102 - Approved'
     1212            'INFO - zope.mgr - K1000000 - %s - Approved' % conid
    12111213            in logcontent)
    12121214        self.assertTrue(
    12131215            'INFO - zope.mgr - customers.browser.ContractsManageFormPage '
    1214             '- K1000000 - removed: c102'
     1216            '- K1000000 - removed: %s' % conid
    12151217            in logcontent)
    12161218
     
    12351237        self.browser.getControl("Add contract").click()
    12361238        self.assertTrue('Sample Contract added.' in self.browser.contents)
    1237         contract = self.customer['contracts']['c102']
     1239        conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0]
     1240        contract = self.customer['contracts'][conid]
    12381241        # Contract can be edited ...
    1239         self.browser.open(self.contracts_path + '/c102/edit')
     1242        self.browser.open(self.contracts_path + '/%s/edit' % conid)
    12401243        #self.browser.getLink("Edit").click()
    12411244        self.assertTrue('The requested form is locked' in self.browser.contents)
    12421245        # Customer is in wrong state
    12431246        IWorkflowState(self.customer).setState(APPROVED)
    1244         self.browser.open(self.contracts_path + '/c102/edit')
     1247        self.browser.open(self.contracts_path + '/%s/edit' % conid)
    12451248        self.browser.getControl(name="form.title").value = 'My second contract'
    12461249        # SAM is in the correct contract_category ...
     
    12491252        self.assertFalse('<option value="LIC">' in self.browser.contents)
    12501253        # So far last_product_id is None.
    1251         self.assertTrue(self.customer['contracts']['c102'].last_product_id is None)
     1254        self.assertTrue(self.customer['contracts'][conid].last_product_id is None)
    12521255        self.browser.getControl(name="form.product_object").value = ['SAM']
    12531256        self.browser.getControl("Save").click()
     
    12581261        self.assertFalse('My first document' in self.browser.contents)
    12591262        IWorkflowState(self.document).setState(SUBMITTED)
    1260         self.browser.open(self.contracts_path + '/c102/edit')
     1263        self.browser.open(self.contracts_path + '/%s/edit' % conid)
    12611264        self.browser.getControl(name="form.product_object").value = ['SAM']
    12621265        self.browser.getControl(name="form.document_object").value = ['DOC1']
     
    12651268        # After saving the form, last_product_id and other attributes are set
    12661269        self.assertTrue('Form has been saved.' in self.browser.contents)
    1267         self.assertEqual(self.customer['contracts']['c102'].last_product_id, 'SAM')
     1270        self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM')
    12681271        self.assertEqual(contract.title, 'My second contract')
    12691272        self.assertEqual(contract.product_object, self.product)
     
    12721275        self.browser.getControl(name="form.title").value = 'My third contract'
    12731276        self.browser.getControl("Save").click()
    1274         self.assertEqual(self.customer['contracts']['c102'].last_product_id, 'SAM')
     1277        self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM')
    12751278        self.assertTrue('Form has been saved.' in self.browser.contents)
    12761279        self.browser.getLink("View").click()
    1277         self.assertEqual(self.browser.url, self.contracts_path + '/c102/index')
     1280        self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid)
    12781281        # An href attribute is referring to the document and product objects
    12791282        self.assertTrue('<a href="http://localhost/app/products/SAM">SAM -'
     
    12901293        self.assertTrue('Contract State: submitted for approval' in self.browser.contents)
    12911294        # Customer can't edit the contract once it has been submitted
    1292         self.browser.open(self.contracts_path + '/c102/edit')
     1295        self.browser.open(self.contracts_path + '/%s/edit' % conid)
    12931296        self.assertTrue('The requested form is locked' in self.browser.contents)
    12941297
     
    13081311        self.contract.document_object = self.document
    13091312        self.contract.product_object = self.product
    1310         self.browser.open(self.customer_path + '/contracts/c101')
     1313        self.browser.open(self.customer_path + '/contracts/CON1')
    13111314        self.browser.getLink("Download contract slip").click()
    13121315        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     
    13381341        IWorkflowState(self.contract).setState('submitted')
    13391342        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    1340         self.browser.open(self.contracts_path + '/c101/trigtrans')
     1343        self.browser.open(self.contracts_path + '/CON1/trigtrans')
    13411344        self.browser.getControl(name="transition").value = ['approve']
    13421345        self.browser.getControl("Apply now").click()
     
    13451348            '<div class="alert alert-warning">Attached documents must be verified first.</div>'
    13461349            in self.browser.contents)
    1347         self.browser.open(self.contracts_path + '/c101/trigtrans')
     1350        self.browser.open(self.contracts_path + '/CON1/trigtrans')
    13481351        IWorkflowState(self.document).setState('verified')
    13491352        self.browser.getControl(name="transition").value = ['approve']
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_catalog.py

    r12256 r12259  
    7777        contract = createObject('waeup.SampleContract')
    7878        contract.title = u'My Samle Contract'
     79        contract.contract_id = u'CON1'
    7980        contract.product_object = product
    8081        contract.document_object = document
     
    195196        logcontent = open(logfile).read()
    196197        self.assertTrue(
    197             'INFO - system - ObjectRemovedEvent - K1000000 - c101 - removed: SAM\n'
     198            'INFO - system - ObjectRemovedEvent - K1000000 - CON1 - removed: SAM\n'
    198199            in logcontent)
    199200
     
    213214        logcontent = open(logfile).read()
    214215        self.assertTrue(
    215             'INFO - system - ObjectRemovedEvent - K1000000 - c101 - removed: %s\n'
     216            'INFO - system - ObjectRemovedEvent - K1000000 - CON1 - removed: %s\n'
    216217            % self.document_id in logcontent)
    217218
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_contract.py

    r12221 r12259  
    6262        self.assertRaises(TypeError, container.addContract, object())
    6363        self.assertEqual(contract.class_name, 'SampleContract')
    64         self.assertEqual(id, 'c999')
    6564        return
    6665
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py

    r12256 r12259  
    249249        # we can export a nearly empty contract
    250250        contract = SampleContract()
     251        contract.contract_id = u'CON1'
    251252        exporter = ContractExporter()
    252253        exporter.export([contract], self.outfile)
     
    258259            'product_object,state,title\r\n'
    259260
    260             'SampleContract,sample,c101,,[],,,,\r\n'
     261            'SampleContract,sample,CON1,,[],,,,\r\n'
    261262            )
    262263        return
     
    274275            'product_object,state,title\r\n'
    275276
    276             'SampleContract,sample,c101,DOC1,[u\'2014-12-04 12:10:46 UTC - '
     277            'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - '
    277278            'Contract created by system\'],,'
    278279            'SAM,created,My Contract\r\n',
     
    293294            'product_object,state,title\r\n'
    294295
    295             'SampleContract,sample,c101,DOC1,[u\'2014-12-04 12:10:46 UTC - '
     296            'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - '
    296297            'Contract created by system\'],,'
    297298            'SAM,created,My Contract\r\n',
     
    312313            'product_object,state,title\r\n'
    313314
    314             'SampleContract,sample,c101,DOC1,[u\'2014-12-04 12:10:46 UTC - '
     315            'SampleContract,sample,CON1,DOC1,[u\'2014-12-04 12:10:46 UTC - '
    315316            'Contract created by system\'],,'
    316317            'SAM,created,My Contract\r\n',
Note: See TracChangeset for help on using the changeset viewer.