Changeset 12318 for main/waeup.ikoba/trunk/src/waeup/ikoba
- Timestamp:
- 25 Dec 2014, 18:23:17 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/products
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/products/browser.py
r12317 r12318 177 177 @action(_('Save'), style='primary') 178 178 def save(self, **data): 179 ##: ToDo Remove unchanged product options from data 179 # Remove unchanged product options from data 180 new_options = data.get('options') 181 if new_options and (len(new_options) == len (self.context.options)): 182 new = False 183 for i in range(len(new_options)): 184 new_option_str = new_options[i].to_string() 185 stored_options_str = self.context.options[i].to_string() 186 if new_option_str != stored_options_str: 187 new = True 188 break 189 if not new: 190 del data['options'] 180 191 return msave(self, **data) 181 192 -
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.