Changeset 12341 for main/waeup.ikoba/trunk/src
- Timestamp:
- 30 Dec 2014, 09:49:24 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12336 r12341 23 23 import pytz 24 24 import base64 25 from decimal import Decimal 25 26 from datetime import datetime, timedelta, date 26 27 from StringIO import StringIO … … 52 53 from waeup.ikoba.interfaces import VERIFIED 53 54 from waeup.ikoba.browser.tests.test_pdf import samples_dir 55 from waeup.ikoba.products.productoptions import ProductOption 54 56 55 57 PH_LEN = 15911 # Length of placeholder file … … 104 106 self.product.title = u'Our Sample Product' 105 107 self.product.contract_category = u'sample' 108 prodoption = ProductOption() 109 prodoption.title = u'First option' 110 prodoption.fee = Decimal('99.9') 111 prodoption.currency = 'usd' 112 self.product.options = [prodoption,] 106 113 self.app['products'].addProduct(self.product) 107 114 … … 1154 1161 # Managers can access the pages of customer contractsconter 1155 1162 # and can perform actions 1163 IWorkflowState(self.customer).setState(APPROVED) 1156 1164 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1157 1165 self.browser.open(self.customer_path) … … 1200 1208 in logcontent) 1201 1209 self.assertTrue( 1202 'INFO - zope.mgr - customers.browser.ContractAdd FormPage '1210 'INFO - zope.mgr - customers.browser.ContractAddPage ' 1203 1211 '- K1000000 - added: Sample Contract %s' 1204 1212 % contract.contract_id in logcontent) … … 1210 1218 in logcontent) 1211 1219 self.assertTrue( 1212 'INFO - zope.mgr - customers.browser.Contracts ManageFormPage '1220 'INFO - zope.mgr - customers.browser.ContractsFormPage ' 1213 1221 '- K1000000 - removed: %s' % conid 1214 1222 in logcontent) … … 1229 1237 '...You logged in...', self.browser.contents) 1230 1238 self.browser.getLink("Contracts").click() 1239 # Customer is in wrong state 1240 self.assertFalse('Add contract' in self.browser.contents) 1241 self.browser.open(self.contracts_path + '/addcontract') 1242 self.assertTrue('The requested form is locked' in self.browser.contents) 1243 IWorkflowState(self.customer).setState(APPROVED) 1244 self.browser.open(self.contracts_path) 1245 # Now customer can add a contract 1231 1246 self.browser.getControl("Add contract").click() 1232 1247 self.browser.getControl(name="contype").value = ['SampleContract'] … … 1235 1250 conid = [i for i in self.customer['contracts'].keys() if len(i) > 10][0] 1236 1251 contract = self.customer['contracts'][conid] 1237 # Contract can be edited ... 1238 self.browser.open(self.contracts_path + '/%s/edit' % conid) 1239 #self.browser.getLink("Edit").click() 1240 self.assertTrue('The requested form is locked' in self.browser.contents) 1241 # Customer is in wrong state 1242 IWorkflowState(self.customer).setState(APPROVED) 1243 self.browser.open(self.contracts_path + '/%s/edit' % conid) 1252 self.assertEqual( 1253 self.browser.url, self.contracts_path + '/%s/selectproduct' % conid) 1244 1254 # SAM is in the correct contract_category ... 1245 1255 self.assertTrue('<option value="SAM">' in self.browser.contents) … … 1249 1259 self.assertTrue(self.customer['contracts'][conid].last_product_id is None) 1250 1260 self.browser.getControl(name="form.product_object").value = ['SAM'] 1261 self.browser.getControl("Save and proceed").click() 1262 self.assertEqual( 1263 self.browser.url, self.contracts_path + '/%s/edit' % conid) 1264 # Document is a required field on edit form page. 1251 1265 self.browser.getControl("Save").click() 1252 # Document is a required field on edit form page.1253 1266 self.assertTrue('Document: <span class="error">Required input is missing.</span>' 1254 1267 in self.browser.contents) … … 1257 1270 IWorkflowState(self.document).setState(SUBMITTED) 1258 1271 self.browser.open(self.contracts_path + '/%s/edit' % conid) 1259 self.browser.getControl(name="form.product_object").value = ['SAM']1260 1272 self.browser.getControl(name="form.document_object").value = ['DOC1'] 1261 1273 self.browser.getControl("Save").click() … … 1270 1282 self.assertEqual(self.customer['contracts'][conid].last_product_id, 'SAM') 1271 1283 self.assertTrue('Form has been saved.' in self.browser.contents) 1284 # So far we have not yet set product options. 1285 # Unfortunately, we can't set them in test browser 1286 prodoption = ProductOption() 1287 prodoption.title = u'Any product option' 1288 prodoption.fee = Decimal('88.8') 1289 prodoption.currency = 'eur' 1290 contract.product_options = [prodoption,] 1291 self.browser.open(self.contracts_path + '/%s/edit' % conid) 1292 # We can see both the stored and the recent product options 1293 # from the chosen product. 1294 self.assertTrue('<option selected="selected" value="Any product option">' 1295 'Any product option @ 88.8 eur</option>' 1296 in self.browser.contents) 1297 self.assertTrue('<option value="First option">First option ' 1298 '@ 99.9 usd</option>' in self.browser.contents) 1299 # In test browser we can at least replace the option 1300 self.browser.getControl( 1301 name="form.product_options.0.").value = ['First option'] 1302 self.assertEqual(contract.product_options[0].title, 'Any product option') 1303 self.browser.getControl("Save").click() 1304 self.assertEqual(contract.product_options[0].title, 'First option') 1272 1305 self.browser.getLink("View").click() 1306 self.assertTrue('<span>First option @ 99.9 usd</span>' in self.browser.contents) 1273 1307 self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid) 1274 1308 # An href attribute is referring to the document and product objects
Note: See TracChangeset for help on using the changeset viewer.