Changeset 12692 for main/waeup.ikoba/branches/uli-payments/src/waeup
- Timestamp:
- 8 Mar 2015, 19:40:47 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/tests/test_browser.py
r12691 r12692 1 1 ## $Id$ 2 ## 2 ## 3 3 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann 4 4 ## This program is free software; you can redistribute it and/or modify … … 6 6 ## the Free Software Foundation; either version 2 of the License, or 7 7 ## (at your option) any later version. 8 ## 8 ## 9 9 ## This program is distributed in the hope that it will be useful, 10 10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of 11 11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 12 ## GNU General Public License for more details. 13 ## 13 ## 14 14 ## You should have received a copy of the GNU General Public License 15 15 ## along with this program; if not, write to the Free Software … … 62 62 SAMPLE_PDF = os.path.join(os.path.dirname(__file__), 'test_pdf.pdf') 63 63 64 64 65 def lookup_submit_value(name, value, browser): 65 66 """Find a button with a certain value.""" … … 72 73 break 73 74 return None 75 74 76 75 77 class CustomersFullSetup(FunctionalTestCase): … … 119 121 prodoption.fee = Decimal('99.9') 120 122 prodoption.currency = 'USD' 121 self.product.options = [prodoption, ]123 self.product.options = [prodoption, ] 122 124 self.app['products'].addProduct(self.product) 123 125 … … 138 140 self.document.document_id = u'DOC1' 139 141 self.assertRaises( 140 NotIdValue, setattr, self.document, 'document_id', u'id with spaces') 142 NotIdValue, setattr, self.document, 'document_id', 143 u'id with spaces') 141 144 self.customer['documents'].addDocument(self.document) 142 145 self.contract = createObject(self._contract_factory) 143 146 self.contract.contract_id = u'CON1' 144 147 self.assertRaises( 145 NotIdValue, setattr, self.contract, 'contract_id', u'id with spaces') 148 NotIdValue, setattr, self.contract, 'contract_id', 149 u'id with spaces') 146 150 self.customer['contracts'].addContract(self.contract) 147 151 … … 299 303 return 300 304 305 301 306 class OfficerUITests(CustomersFullSetup): 302 307 # Tests for Customer class views and pages 303 304 308 305 309 def setup_logging(self): … … 331 335 self.browser.getLink("Logout").click() 332 336 self.assertTrue('You have been logged out' in self.browser.contents) 333 # But we are still logged in since we've used basic authentication here. 334 # Wikipedia says: Existing browsers retain authentication information 335 # until the tab or browser is closed or the user clears the history. 336 # HTTP does not provide a method for a server to direct clients to 337 # discard these cached credentials. This means that there is no 338 # effective way for a server to "log out" the user without closing 339 # the browser. This is a significant defect that requires browser 340 # manufacturers to support a "logout" user interface element ... 337 # But we are still logged in since we've used basic 338 # authentication here. Wikipedia says: Existing browsers 339 # retain authentication information until the tab or browser 340 # is closed or the user clears the history. HTTP does not 341 # provide a method for a server to direct clients to discard 342 # these cached credentials. This means that there is no 343 # effective way for a server to "log out" the user without 344 # closing the browser. This is a significant defect that 345 # requires browser manufacturers to support a "logout" user 346 # interface element ... 341 347 self.assertTrue('Manager' in self.browser.contents) 342 348 … … 378 384 self.browser.open(self.customer_path) 379 385 self.browser.getLink("Send email").click() 380 self.browser.getControl(name="form.subject").value = 'Important subject' 386 self.browser.getControl( 387 name="form.subject").value = 'Important subject' 381 388 self.browser.getControl(name="form.body").value = 'Hello!' 382 389 self.browser.getControl("Send message now").click() … … 409 416 self.browser.getControl('Delete').click() 410 417 self.assertTrue('passport.jpg deleted' in self.browser.contents) 411 412 418 413 419 def test_manage_workflow_send_transition_information(self): … … 459 465 self.browser.getControl("Apply").click() 460 466 self.browser.open(self.trigtrans_path) 461 self.browser.getControl(name="transition").value = ['approve_provisionally'] 467 self.browser.getControl(name="transition").value = [ 468 'approve_provisionally'] 462 469 self.browser.getControl("Apply").click() 463 470 self.browser.open(self.trigtrans_path) … … 499 506 self.browser.getControl('Perform import').click() 500 507 self.assertTrue('Processing of 1 rows failed' in self.browser.contents) 501 self.assertTrue('Successfully processed 2 rows' in self.browser.contents) 508 self.assertTrue( 509 'Successfully processed 2 rows' in self.browser.contents) 502 510 self.assertTrue('Batch processing finished' in self.browser.contents) 503 511 … … 535 543 self.browser.getLink("History").click() 536 544 self.assertTrue( 537 'Customer account deactivated by Manager<br />' in self.browser.contents) 538 self.assertTrue( 539 'Customer account activated by Manager<br />' in self.browser.contents) 545 'Customer account deactivated by Manager<br />' 546 in self.browser.contents) 547 self.assertTrue( 548 'Customer account activated by Manager<br />' 549 in self.browser.contents) 540 550 # ... and actions have been logged. 541 551 logfile = os.path.join( 542 552 self.app['datacenter'].storage, 'logs', 'customers.log') 543 553 logcontent = open(logfile).read() 544 self.assertTrue('zope.mgr - customers.browser.CustomerDeactivatePage - ' 545 'K1000000 - account deactivated' in logcontent) 546 self.assertTrue('zope.mgr - customers.browser.CustomerActivatePage - ' 547 'K1000000 - account activated' in logcontent) 548 554 self.assertTrue( 555 'zope.mgr - customers.browser.CustomerDeactivatePage - ' 556 'K1000000 - account deactivated' in logcontent) 557 self.assertTrue( 558 'zope.mgr - customers.browser.CustomerActivatePage - ' 559 'K1000000 - account activated' in logcontent) 549 560 550 561 def test_login_as_customer(self): … … 554 565 self.app['users']['mrofficer'].title = 'Harry Actor' 555 566 prmglobal = IPrincipalRoleManager(self.app) 556 prmglobal.assignRoleToPrincipal('waeup.CustomerImpersonator', 'mrofficer') 567 prmglobal.assignRoleToPrincipal( 568 'waeup.CustomerImpersonator', 'mrofficer') 557 569 prmglobal.assignRoleToPrincipal('waeup.CustomersManager', 'mrofficer') 558 570 self.assertEqual(self.customer.state, 'created') … … 574 586 # We are logged in as customer and can see the 'My Data' tab 575 587 self.assertMatches( 576 '...<a href="#" class="dropdown-toggle" data-toggle="dropdown">...', 588 '...<a href="#" class="dropdown-toggle"' 589 ' data-toggle="dropdown">...', 577 590 self.browser.contents) 578 591 self.assertMatches( … … 724 737 self.assertMatches( 725 738 '...<div class="alert alert-warning">' 726 'Your account has been deactivated.</div>...', self.browser.contents) 739 'Your account has been deactivated.</div>...', 740 self.browser.contents) 727 741 # If suspended_comment is set this message will be flashed instead 728 742 self.customer.suspended_comment = u'Aetsch baetsch!' … … 778 792 self.assertTrue('An email with' in self.browser.contents) 779 793 794 780 795 class CustomerRegistrationTests(CustomersFullSetup): 781 796 # Tests for customer registration … … 823 838 cat.searchResults( 824 839 email=('new@yy.zz', 'new@yy.zz'))) 825 self.assertEqual(self.customer, results[0])840 self.assertEqual(self.customer, results[0]) 826 841 logfile = os.path.join( 827 842 self.app['datacenter'].storage, 'logs', 'main.log') 828 843 logcontent = open(logfile).read() 829 self.assertTrue('zope.anybody - customers.browser.CustomerRequestPasswordPage - ' 830 '123 (K1000000) - new@yy.zz' in logcontent) 844 self.assertTrue( 845 'zope.anybody - customers.browser.CustomerRequestPasswordPage - ' 846 '123 (K1000000) - new@yy.zz' in logcontent) 831 847 return 832 848 … … 841 857 self.browser.getControl(name="form.email").value = 'newcustomer@xx.zz' 842 858 self.browser.getControl("Send login credentials").click() 843 self.assertTrue('Your request was successful.' in self.browser.contents) 859 self.assertTrue( 860 'Your request was successful.' in self.browser.contents) 844 861 # Customer can be found in the catalog via the email address 845 862 cat = queryUtility(ICatalog, name='customers_catalog') … … 849 866 self.assertEqual(self.app['customers']['K1000001'], results[0]) 850 867 self.assertEqual(self.app['customers']['K1000001'].firstname, 'Ruben') 851 self.assertEqual(self.app['customers']['K1000001'].lastname, 'Gonzales') 868 self.assertEqual( 869 self.app['customers']['K1000001'].lastname, 'Gonzales') 852 870 logfile = os.path.join( 853 871 self.app['datacenter'].storage, 'logs', 'main.log') 854 872 logcontent = open(logfile).read() 855 self.assertTrue('zope.anybody - customers.browser.CustomerCreateAccountPage - ' 856 'K1000001 - newcustomer@xx.zz' in logcontent) 873 self.assertTrue( 874 'zope.anybody - customers.browser.CustomerCreateAccountPage - ' 875 'K1000001 - newcustomer@xx.zz' in logcontent) 857 876 return 877 858 878 859 879 class CustomerDataExportTests(CustomersFullSetup, FunctionalAsyncTestCase): … … 929 949 self.browser.getControl("Add document").click() 930 950 self.assertTrue('PDF Document added.' in self.browser.contents) 931 docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0] 951 docid = [i for i in self.customer['documents'].keys() 952 if len(i) > 10][0] 932 953 document = self.customer['documents'][docid] 933 954 … … 950 971 self.browser.getControl(name="transition").value = ['verify'] 951 972 self.browser.getControl("Apply").click() 952 self.assertTrue('Customer has not yet been approved' in self.browser.contents) 973 self.assertTrue( 974 'Customer has not yet been approved' in self.browser.contents) 953 975 IWorkflowState(self.customer).setState(APPROVED) 954 976 # Document can only be verified if files have been uploaded before … … 958 980 self.assertTrue('No file uploaded' in self.browser.contents) 959 981 self.assertEqual(document.state, 'submitted') 960 # We set state here manually (verification is tested in test_verify_document) 982 # We set state here manually (verification is tested in 983 # test_verify_document) 961 984 IWorkflowState(document).setState(VERIFIED) 962 985 … … 964 987 self.browser.open(self.documents_path + '/' + docid + '/index') 965 988 self.assertFalse( 966 'href="http://localhost/app/customers/K1000000/documents/%s/manage"' 989 'href="http://localhost/app/customers/K1000000/' 990 'documents/%s/manage"' 967 991 % docid in self.browser.contents) 968 992 self.browser.open(self.documents_path + '/' + docid + '/manage') … … 1012 1036 self.browser.getLink("Documents").click() 1013 1037 self.browser.getControl("Add document").click() 1014 self.assertTrue('The requested form is locked' in self.browser.contents) 1038 self.assertTrue( 1039 'The requested form is locked' in self.browser.contents) 1015 1040 # Customer is in wrong state 1016 1041 IWorkflowState(self.customer).setState(APPROVED) 1017 1042 self.browser.getControl("Add document").click() 1018 self.browser.getControl(name="doctype").value = ['CustomerSampleDocument'] 1043 self.browser.getControl(name="doctype").value = [ 1044 'CustomerSampleDocument'] 1019 1045 self.browser.getControl(name="form.title").value = 'My Sample Document' 1020 1046 self.browser.getControl("Add document").click() 1021 1047 self.assertTrue('Sample Document added.' in self.browser.contents) 1022 docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0] 1048 docid = [i for i in self.customer['documents'].keys() 1049 if len(i) > 10][0] 1023 1050 document = self.customer['documents'][docid] 1024 1051 self.browser.getControl(name="form.title").value = 'My second doc' … … 1038 1065 name='upload_samplescaneditupload').click() 1039 1066 self.assertTrue( 1040 'href="http://localhost/app/customers/K1000000/documents/%s/sample"' 1067 'href="http://localhost/app/customers/K1000000/' 1068 'documents/%s/sample"' 1041 1069 % docid in self.browser.contents) 1042 1070 # Customer can submit the form. The form is also saved. … … 1045 1073 self.assertEqual(document.title, 'My third doc') 1046 1074 self.assertEqual(document.state, 'submitted') 1047 self.assertTrue('Document State: submitted for verification' in self.browser.contents) 1075 self.assertTrue( 1076 'Document State: submitted for verification' 1077 in self.browser.contents) 1048 1078 # Customer can't edit the document once it has been submitted 1049 1079 self.browser.open(self.documents_path + '/%s/edit' % docid) 1050 self.assertTrue('The requested form is locked' in self.browser.contents) 1080 self.assertTrue( 1081 'The requested form is locked' in self.browser.contents) 1051 1082 1052 1083 def test_manage_upload_sample_file(self): … … 1055 1086 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1056 1087 self.browser.open(self.customer_path + '/documents/DOC1/manage') 1057 # Create a pseudo image file and select it to be uploaded 1088 # Create a pseudo image file and select it to be uploaded 1058 1089 image = open(SAMPLE_IMAGE, 'rb') 1059 1090 ctrl = self.browser.getControl(name='samplescanmanageupload') … … 1061 1092 file_ctrl.add_file(image, filename='my_sample_scan.jpg') 1062 1093 # The Save action does not upload files 1063 self.browser.getControl("Save").click() # submit form1094 self.browser.getControl("Save").click() # submit form 1064 1095 self.assertFalse( 1065 'href="http://localhost/app/customers/K1000000/documents/DOC1/sample"' 1096 'href="http://localhost/app/customers/K1000000/' 1097 'documents/DOC1/sample"' 1066 1098 in self.browser.contents) 1067 1099 # ... but the correct upload submit button does … … 1073 1105 name='upload_samplescanmanageupload').click() 1074 1106 self.assertTrue( 1075 'href="http://localhost/app/customers/K1000000/documents/DOC1/sample"' 1107 'href="http://localhost/app/customers/K1000000/' 1108 'documents/DOC1/sample"' 1076 1109 in self.browser.contents) 1077 1110 # Browsing the link shows a real image … … 1098 1131 'Uploaded file is too big' in self.browser.contents) 1099 1132 # We do not rely on filename extensions given by uploaders 1100 image = open(SAMPLE_IMAGE, 'rb') # a jpg-file1133 image = open(SAMPLE_IMAGE, 'rb') # a jpg-file 1101 1134 ctrl = self.browser.getControl(name='samplescanmanageupload') 1102 1135 file_ctrl = ctrl.mech_control … … 1152 1185 self.browser.getControl(name="form.title").value = 'My PDF Document' 1153 1186 self.browser.getControl("Add document").click() 1154 docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0] 1187 docid = [ 1188 i for i in self.customer['documents'].keys() if len(i) > 10][0] 1155 1189 self.browser.open(self.documents_path + '/%s/manage' % docid) 1156 1190 # Create a pseudo image file and select it to be uploaded … … 1177 1211 name='upload_pdfscanmanageupload').click() 1178 1212 self.assertTrue( 1179 'href="http://localhost/app/customers/K1000000/documents/%s/sample.pdf">%s.pdf</a>' 1213 'href="http://localhost/app/customers/K1000000/' 1214 'documents/%s/sample.pdf">%s.pdf</a>' 1180 1215 % (docid, docid[:9]) in self.browser.contents) 1181 1216 # Browsing the link shows a real pdf … … 1194 1229 self.browser.getLink("Download documents overview").click() 1195 1230 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1196 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 1231 self.assertEqual( 1232 self.browser.headers['Content-Type'], 'application/pdf') 1197 1233 path = os.path.join(samples_dir(), 'documents_overview_slip.pdf') 1198 1234 open(path, 'wb').write(self.browser.contents) … … 1200 1236 # Officers can open document slips which shows a thumbnail of 1201 1237 # the jpeg file attached. 1202 file_id = IFileStoreNameChooser(self.document).chooseName(attr='sample.jpg') 1238 file_id = IFileStoreNameChooser(self.document).chooseName( 1239 attr='sample.jpg') 1203 1240 fs = ExtFileStore(root=self.dc_root) 1204 1241 jpegfile = open(SAMPLE_IMAGE, 'rb') … … 1207 1244 self.browser.getLink("Download document slip").click() 1208 1245 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1209 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 1246 self.assertEqual( 1247 self.browser.headers['Content-Type'], 'application/pdf') 1210 1248 path = os.path.join(samples_dir(), 'document_slip.pdf') 1211 1249 open(path, 'wb').write(self.browser.contents) … … 1216 1254 self.customer['documents'].addDocument(pdfdocument) 1217 1255 # Add pdf file 1218 file_id = IFileStoreNameChooser(pdfdocument).chooseName(attr='sample.pdf') 1256 file_id = IFileStoreNameChooser(pdfdocument).chooseName( 1257 attr='sample.pdf') 1219 1258 fs = ExtFileStore(root=self.dc_root) 1220 1259 pdffile = open(SAMPLE_PDF, 'rb') 1221 1260 fs.createFile(file_id, pdffile) 1222 docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0] 1261 docid = [i for i in self.customer['documents'].keys() 1262 if len(i) > 10][0] 1223 1263 self.browser.open(self.customer_path + '/documents/' + docid) 1224 1264 self.browser.getLink("Download document slip").click() 1225 1265 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1226 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 1266 self.assertEqual( 1267 self.browser.headers['Content-Type'], 'application/pdf') 1227 1268 path = os.path.join(samples_dir(), 'pdfdocument_slip.pdf') 1228 1269 open(path, 'wb').write(self.browser.contents) … … 1232 1273 # A proper file name chooser is registered for customer documents. 1233 1274 # This is not a UI test. It's just a functional test. 1234 file_id = IFileStoreNameChooser(self.document).chooseName(attr='sample') 1275 file_id = IFileStoreNameChooser(self.document).chooseName( 1276 attr='sample') 1235 1277 fs = ExtFileStore(root=self.dc_root) 1236 1278 fs.createFile(file_id, StringIO('my sample 1')) 1237 1279 result = fs.getFileByContext(self.document, attr='sample') 1238 self.assertEqual(file_id, '__file-customerdocument__01000/K1000000/sample_DOC1_K1000000') 1280 self.assertEqual( 1281 file_id, '__file-customerdocument__01000/' 1282 'K1000000/sample_DOC1_K1000000') 1239 1283 self.assertEqual(result.read(), 'my sample 1') 1240 self.assertEqual(self.document.connected_files[0][1].read(), 'my sample 1') 1284 self.assertEqual( 1285 self.document.connected_files[0][1].read(), 'my sample 1') 1241 1286 self.document.setMD5() 1242 self.assertEqual(self.document.sample_md5, 'a406995ee8eb6772bacf51aa4b0caa24') 1287 self.assertEqual( 1288 self.document.sample_md5, 'a406995ee8eb6772bacf51aa4b0caa24') 1243 1289 return 1244 1290 … … 1261 1307 self.browser.getControl("Add contract").click() 1262 1308 self.assertTrue('Sample Contract added.' in self.browser.contents) 1263 conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0] 1309 conid = [i for i in self.customer['contracts'].keys() 1310 if len(i) > 10][0] 1264 1311 contract = self.customer['contracts'][conid] 1265 1312 self.assertEqual( 1266 self.browser.url, self.contracts_path + '/%s/selectproduct' % conid) 1313 self.browser.url, 1314 self.contracts_path + '/%s/selectproduct' % conid) 1267 1315 # SAM is in the correct contract_category 1268 1316 self.assertTrue('<option value="SAM">' in self.browser.contents) 1269 1317 # So far last_product_id is None. 1270 self.assertTrue(self.customer['contracts'][conid].last_product_id is None) 1318 self.assertTrue( 1319 self.customer['contracts'][conid].last_product_id is None) 1271 1320 self.browser.getControl(name="form.product_object").value = ['SAM'] 1272 1321 self.browser.getControl("Save and proceed").click() … … 1274 1323 self.browser.url, self.contracts_path + '/%s/manage' % conid) 1275 1324 self.browser.getLink("View").click() 1276 self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid) 1325 self.assertEqual( 1326 self.browser.url, self.contracts_path + '/%s/index' % conid) 1277 1327 self.assertEqual(contract.tc_dict, {'en': u'Hello world'}) 1278 1328 … … 1342 1392 self.assertFalse('Add contract' in self.browser.contents) 1343 1393 self.browser.open(self.contracts_path + '/addcontract') 1344 self.assertTrue('The requested form is locked' in self.browser.contents) 1394 self.assertTrue( 1395 'The requested form is locked' in self.browser.contents) 1345 1396 IWorkflowState(self.customer).setState(APPROVED) 1346 1397 self.browser.open(self.contracts_path) … … 1350 1401 self.browser.getControl("Add contract").click() 1351 1402 self.assertTrue('Sample Contract added.' in self.browser.contents) 1352 conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0] 1403 conid = [i for i in self.customer['contracts'].keys() 1404 if len(i) > 10][0] 1353 1405 contract = self.customer['contracts'][conid] 1354 1406 self.assertEqual( 1355 self.browser.url, self.contracts_path + '/%s/selectproduct' % conid) 1407 self.browser.url, 1408 self.contracts_path + '/%s/selectproduct' % conid) 1356 1409 # SAM is in the correct contract_category ... 1357 1410 self.assertTrue('<option value="SAM">' in self.browser.contents) … … 1359 1412 self.assertFalse('<option value="LIC">' in self.browser.contents) 1360 1413 # So far last_product_id is None. 1361 self.assertTrue(self.customer['contracts'][conid].last_product_id is None) 1414 self.assertTrue( 1415 self.customer['contracts'][conid].last_product_id is None) 1362 1416 self.browser.getControl(name="form.product_object").value = ['SAM'] 1363 1417 self.browser.getControl("Save and proceed").click() … … 1366 1420 # Document is a required field on edit form page. 1367 1421 self.browser.getControl("Save").click() 1368 self.assertTrue('Document: <span class="error">Required input is missing.</span>' 1422 self.assertTrue( 1423 'Document: <span class="error">Required input is missing.</span>' 1369 1424 in self.browser.contents) 1370 1425 # But our document can't be selected because it's not submitted … … 1376 1431 # After saving the form, last_product_id and other attributes are set 1377 1432 self.assertTrue('Form has been saved.' in self.browser.contents) 1378 self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM') 1433 self.assertEqual( 1434 self.customer['contracts'][conid].last_product_id, 'SAM') 1379 1435 self.assertEqual(contract.title, 'Our Sample Product') 1380 1436 self.assertEqual(contract.product_object, self.product) … … 1382 1438 # Saving the form again does not unset last_product_id 1383 1439 self.browser.getControl("Save").click() 1384 self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM') 1440 self.assertEqual( 1441 self.customer['contracts'][conid].last_product_id, 'SAM') 1385 1442 self.assertTrue('Form has been saved.' in self.browser.contents) 1386 1443 # So far we have not yet set product options. … … 1390 1447 prodoption.fee = Decimal('88.8') 1391 1448 prodoption.currency = 'EUR' 1392 contract.product_options = [prodoption, ]1449 contract.product_options = [prodoption, ] 1393 1450 self.browser.open(self.contracts_path + '/%s/edit' % conid) 1394 1451 # We can see both the stored and the recent product options 1395 1452 # from the chosen product. 1396 self.assertTrue('<option selected="selected" value="Any product option">' 1397 'Any product option @ 88.8 Euro</option>' 1398 in self.browser.contents) 1453 self.assertTrue( 1454 '<option selected="selected" value="Any product option">' 1455 'Any product option @ 88.8 Euro</option>' 1456 in self.browser.contents) 1399 1457 self.assertTrue('<option value="First option">First option ' 1400 1458 '@ 99.9 US Dollar</option>' in self.browser.contents) … … 1402 1460 self.browser.getControl( 1403 1461 name="form.product_options.0.").value = ['First option'] 1404 self.assertEqual(contract.product_options[0].title, 'Any product option') 1462 self.assertEqual( 1463 contract.product_options[0].title, 'Any product option') 1405 1464 self.browser.getControl("Save").click() 1406 1465 self.assertEqual(contract.product_options[0].title, 'First option') 1407 1466 self.browser.getLink("View").click() 1408 self.assertTrue('<span>First option @ 99.9 US Dollar</span>' in self.browser.contents) 1409 self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid) 1467 self.assertTrue( 1468 '<span>First option @ 99.9 US Dollar</span>' 1469 in self.browser.contents) 1470 self.assertEqual( 1471 self.browser.url, self.contracts_path + '/%s/index' % conid) 1410 1472 # An href attribute is referring to the document and product objects 1411 1473 self.assertTrue('<a href="http://localhost/app/products/SAM">SAM -' 1412 1474 in self.browser.contents) 1413 1475 self.assertTrue( 1414 '<a href="http://localhost/app/customers/K1000000/documents/DOC1">DOC1 -' 1476 '<a href="http://localhost/app/customers/K1000000/' 1477 'documents/DOC1">DOC1 -' 1415 1478 in self.browser.contents) 1416 1479 # Customer can submit the form if confirmation box is ticket. … … 1418 1481 self.browser.getLink("Edit").click() 1419 1482 self.browser.getControl("Proceed to checkout").click() 1420 self.assertTrue('confirm your acceptance of these by ticking' in self.browser.contents) 1483 self.assertTrue( 1484 'confirm your acceptance of these by ticking' 1485 in self.browser.contents) 1421 1486 self.assertEqual(contract.state, 'created') 1422 1487 self.browser.getControl(name="confirm_tc").value = True … … 1429 1494 # Customer can't edit the contract once it has been submitted 1430 1495 self.browser.open(self.contracts_path + '/%s/edit' % conid) 1431 self.assertTrue('The requested form is locked' in self.browser.contents) 1496 self.assertTrue( 1497 'The requested form is locked' in self.browser.contents) 1432 1498 1433 1499 def test_view_slips(self): … … 1437 1503 self.browser.getLink("Download contracts overview").click() 1438 1504 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1439 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 1505 self.assertEqual( 1506 self.browser.headers['Content-Type'], 'application/pdf') 1440 1507 path = os.path.join(samples_dir(), 'contracts_overview_slip.pdf') 1441 1508 open(path, 'wb').write(self.browser.contents) … … 1453 1520 self.browser.getLink("Download contract slip").click() 1454 1521 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1455 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 1522 self.assertEqual( 1523 self.browser.headers['Content-Type'], 'application/pdf') 1456 1524 path = os.path.join(samples_dir(), 'contract_slip.pdf') 1457 1525 open(path, 'wb').write(self.browser.contents) … … 1488 1556 # InvalidTransitionError is catched 1489 1557 self.assertTrue( 1490 '<div class="alert alert-warning">Attached documents must be verified first.</div>' 1558 '<div class="alert alert-warning">Attached documents ' 1559 'must be verified first.</div>' 1491 1560 in self.browser.contents) 1492 1561 self.browser.open(self.contracts_path + '/CON1/trigtrans') … … 1501 1570 prodoption.fee = Decimal('88.8') 1502 1571 prodoption.currency = 'EUR' 1503 contract.product_options = [prodoption, ]1572 contract.product_options = [prodoption, ] 1504 1573 1505 1574 def prepare_payment_select(self):
Note: See TracChangeset for help on using the changeset viewer.