Changeset 12318 for main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests
- Timestamp:
- 25 Dec 2014, 18:23:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_browser.py
r12288 r12318 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 … … 43 44 from waeup.ikoba.tests.test_async import FunctionalAsyncTestCase 44 45 from waeup.ikoba.browser.tests.test_pdf import samples_dir 46 from waeup.ikoba.products.productoptions import ProductOptionEntry 45 47 46 48 def lookup_submit_value(name, value, browser): … … 83 85 # to access grok.getSite() and should get our new app then 84 86 setSite(app) 87 88 self.logfile = os.path.join( 89 self.app['datacenter'].storage, 'logs', 'main.log') 85 90 86 91 # Add user … … 211 216 None) 212 217 return 218 219 def test_product_options(self): 220 prodoptions = ProductOptionEntry() 221 prodoptions.title = u'My option' 222 prodoptions.fee = Decimal('99.9') 223 prodoptions.currency = 'usd' 224 self.product.options = [prodoptions,] 225 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 226 self.browser.open(self.product_path) 227 self.assertEqual(self.browser.headers['Status'], '200 Ok') 228 self.assertEqual(self.product.options[0], prodoptions) 229 self.browser.open(self.manage_product_path) 230 self.browser.getControl("Save").click() 231 # applyData must not exchange the object 232 self.assertEqual(self.product.options[0], prodoptions) 233 # and thus not add a logging message (the log file 234 # do not even exist so far) 235 self.assertRaises(IOError, open, self.logfile, 'read') 236 # Now we change the content after opening the manage page 237 self.browser.open(self.manage_product_path) 238 prodoptions.title = u'My new option' 239 self.assertEqual(self.product.options[0].title, 'My new option') 240 # but save the opened form with the old data. 241 self.browser.getControl("Save").click() 242 # The object has been replaced, 243 self.assertTrue(self.product.options[0] != prodoptions) 244 # the old title has been restored 245 self.assertEqual(self.product.options[0].title, 'My option') 246 # and a logging message has been added. 247 logcontent = open(self.logfile).read() 248 self.assertTrue('saved: options' in logcontent)
Note: See TracChangeset for help on using the changeset viewer.