- Timestamp:
- 18 Dec 2014, 15:47:12 (10 years ago)
- 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 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 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12256 r12259 124 124 self.contract = createObject('waeup.SampleContract') 125 125 self.contract.title = u'My first contract' 126 self.contract.contract_id = u'CON1' 126 127 self.customer['contracts'].addContract(self.contract) 127 128 … … 1161 1162 self.browser.getControl("Add contract").click() 1162 1163 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] 1164 1166 1165 1167 # Contract can be edited 1166 self.browser.getLink( "c102").click()1168 self.browser.getLink(conid).click() 1167 1169 self.browser.getLink("Manage").click() 1168 1170 self.browser.getControl(name="form.product_object").value = ['SAM'] … … 1171 1173 self.assertTrue('Form has been saved.' in self.browser.contents) 1172 1174 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) 1174 1176 1175 1177 # Transitions can be performed … … 1194 1196 logcontent = open(logfile).read() 1195 1197 self.assertTrue( 1196 'INFO - zope.mgr - K1000000 - c102 - Contract created'1198 'INFO - zope.mgr - K1000000 - %s - Contract created' % conid 1197 1199 in logcontent) 1198 1200 self.assertTrue( … … 1202 1204 self.assertTrue( 1203 1205 'INFO - zope.mgr - customers.browser.ContractManageFormPage ' 1204 '- K1000000 - c102 - saved: title'1206 '- K1000000 - %s - saved: title' % conid 1205 1207 in logcontent) 1206 1208 self.assertTrue( 1207 'INFO - zope.mgr - K1000000 - c102 - Submitted for approval'1209 'INFO - zope.mgr - K1000000 - %s - Submitted for approval' % conid 1208 1210 in logcontent) 1209 1211 self.assertTrue( 1210 'INFO - zope.mgr - K1000000 - c102 - Approved'1212 'INFO - zope.mgr - K1000000 - %s - Approved' % conid 1211 1213 in logcontent) 1212 1214 self.assertTrue( 1213 1215 'INFO - zope.mgr - customers.browser.ContractsManageFormPage ' 1214 '- K1000000 - removed: c102'1216 '- K1000000 - removed: %s' % conid 1215 1217 in logcontent) 1216 1218 … … 1235 1237 self.browser.getControl("Add contract").click() 1236 1238 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] 1238 1241 # Contract can be edited ... 1239 self.browser.open(self.contracts_path + '/ c102/edit')1242 self.browser.open(self.contracts_path + '/%s/edit' % conid) 1240 1243 #self.browser.getLink("Edit").click() 1241 1244 self.assertTrue('The requested form is locked' in self.browser.contents) 1242 1245 # Customer is in wrong state 1243 1246 IWorkflowState(self.customer).setState(APPROVED) 1244 self.browser.open(self.contracts_path + '/ c102/edit')1247 self.browser.open(self.contracts_path + '/%s/edit' % conid) 1245 1248 self.browser.getControl(name="form.title").value = 'My second contract' 1246 1249 # SAM is in the correct contract_category ... … … 1249 1252 self.assertFalse('<option value="LIC">' in self.browser.contents) 1250 1253 # 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) 1252 1255 self.browser.getControl(name="form.product_object").value = ['SAM'] 1253 1256 self.browser.getControl("Save").click() … … 1258 1261 self.assertFalse('My first document' in self.browser.contents) 1259 1262 IWorkflowState(self.document).setState(SUBMITTED) 1260 self.browser.open(self.contracts_path + '/ c102/edit')1263 self.browser.open(self.contracts_path + '/%s/edit' % conid) 1261 1264 self.browser.getControl(name="form.product_object").value = ['SAM'] 1262 1265 self.browser.getControl(name="form.document_object").value = ['DOC1'] … … 1265 1268 # After saving the form, last_product_id and other attributes are set 1266 1269 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') 1268 1271 self.assertEqual(contract.title, 'My second contract') 1269 1272 self.assertEqual(contract.product_object, self.product) … … 1272 1275 self.browser.getControl(name="form.title").value = 'My third contract' 1273 1276 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') 1275 1278 self.assertTrue('Form has been saved.' in self.browser.contents) 1276 1279 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) 1278 1281 # An href attribute is referring to the document and product objects 1279 1282 self.assertTrue('<a href="http://localhost/app/products/SAM">SAM -' … … 1290 1293 self.assertTrue('Contract State: submitted for approval' in self.browser.contents) 1291 1294 # 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) 1293 1296 self.assertTrue('The requested form is locked' in self.browser.contents) 1294 1297 … … 1308 1311 self.contract.document_object = self.document 1309 1312 self.contract.product_object = self.product 1310 self.browser.open(self.customer_path + '/contracts/ c101')1313 self.browser.open(self.customer_path + '/contracts/CON1') 1311 1314 self.browser.getLink("Download contract slip").click() 1312 1315 self.assertEqual(self.browser.headers['Status'], '200 Ok') … … 1338 1341 IWorkflowState(self.contract).setState('submitted') 1339 1342 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') 1341 1344 self.browser.getControl(name="transition").value = ['approve'] 1342 1345 self.browser.getControl("Apply now").click() … … 1345 1348 '<div class="alert alert-warning">Attached documents must be verified first.</div>' 1346 1349 in self.browser.contents) 1347 self.browser.open(self.contracts_path + '/ c101/trigtrans')1350 self.browser.open(self.contracts_path + '/CON1/trigtrans') 1348 1351 IWorkflowState(self.document).setState('verified') 1349 1352 self.browser.getControl(name="transition").value = ['approve'] -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_catalog.py
r12256 r12259 77 77 contract = createObject('waeup.SampleContract') 78 78 contract.title = u'My Samle Contract' 79 contract.contract_id = u'CON1' 79 80 contract.product_object = product 80 81 contract.document_object = document … … 195 196 logcontent = open(logfile).read() 196 197 self.assertTrue( 197 'INFO - system - ObjectRemovedEvent - K1000000 - c101 - removed: SAM\n'198 'INFO - system - ObjectRemovedEvent - K1000000 - CON1 - removed: SAM\n' 198 199 in logcontent) 199 200 … … 213 214 logcontent = open(logfile).read() 214 215 self.assertTrue( 215 'INFO - system - ObjectRemovedEvent - K1000000 - c101 - removed: %s\n'216 'INFO - system - ObjectRemovedEvent - K1000000 - CON1 - removed: %s\n' 216 217 % self.document_id in logcontent) 217 218 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_contract.py
r12221 r12259 62 62 self.assertRaises(TypeError, container.addContract, object()) 63 63 self.assertEqual(contract.class_name, 'SampleContract') 64 self.assertEqual(id, 'c999')65 64 return 66 65 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py
r12256 r12259 249 249 # we can export a nearly empty contract 250 250 contract = SampleContract() 251 contract.contract_id = u'CON1' 251 252 exporter = ContractExporter() 252 253 exporter.export([contract], self.outfile) … … 258 259 'product_object,state,title\r\n' 259 260 260 'SampleContract,sample, c101,,[],,,,\r\n'261 'SampleContract,sample,CON1,,[],,,,\r\n' 261 262 ) 262 263 return … … 274 275 'product_object,state,title\r\n' 275 276 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 - ' 277 278 'Contract created by system\'],,' 278 279 'SAM,created,My Contract\r\n', … … 293 294 'product_object,state,title\r\n' 294 295 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 - ' 296 297 'Contract created by system\'],,' 297 298 'SAM,created,My Contract\r\n', … … 312 313 'product_object,state,title\r\n' 313 314 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 - ' 315 316 'Contract created by system\'],,' 316 317 'SAM,created,My Contract\r\n',
Note: See TracChangeset for help on using the changeset viewer.