- Timestamp:
- 30 Sep 2012, 20:30:43 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py
r9227 r9261 26 26 from zope.component.hooks import setSite, clearSite 27 27 from zope.security.interfaces import Unauthorized 28 from zope.securitypolicy.interfaces import IPrincipalRoleManager 28 29 from zope.testbrowser.testing import Browser 29 30 from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase … … 213 214 return 214 215 216 def test_export_accesscodes(self): 217 # Create portal manager and CCOfficer 218 self.app['users'].addUser('mrmanager', 'mrmanagersecret') 219 self.app['users']['mrmanager'].email = 'mrmanager@foo.ng' 220 self.app['users']['mrmanager'].title = 'Carlo Pitter' 221 # Assign PortalManager role 222 prmlocal = IPrincipalRoleManager(self.app) 223 prmlocal.assignRoleToPrincipal('waeup.PortalManager', 'mrmanager') 224 self.app['users'].addUser('mrofficer', 'mrofficersecret') 225 self.app['users']['mrofficer'].email = 'mrofficer@foo.ng' 226 self.app['users']['mrofficer'].title = 'Carlos Potter' 227 # Assign CCOfficer role 228 prmlocal.assignRoleToPrincipal('waeup.CCOfficer', 'mrofficer') 229 230 # Login as portal manager 231 self.browser.open('http://localhost/app/login') 232 self.browser.getControl(name="form.login").value = 'mrmanager' 233 self.browser.getControl(name="form.password").value = 'mrmanagersecret' 234 self.browser.getControl("Login").click() 235 236 self.browser.open(self.datacenter_path + '/export') 237 self.assertTrue( 238 '<option value="accesscodebatches">' in self.browser.contents) 239 self.assertTrue('<option value="accesscodes">' in self.browser.contents) 240 self.browser.getControl(name="exporter").value = ['accesscodes'] 241 self.browser.getControl("Create CSV file").click() 242 job_id = self.wait_for_export_job_completed() 243 try: 244 self.browser.getControl("Reload").click() 245 except LookupError: 246 pass 247 self.browser.getControl("Download").click() 248 self.assertEqual(self.browser.headers['content-type'], 249 'text/csv; charset=UTF-8') 250 self.assertEqual( 251 'batch_num,batch_prefix,batch_serial,cost,history,owner,' 252 'random_num,representation,state\r\n', 253 self.browser.contents) 254 255 # Login as officer who is not allowed to download accesscodes 256 self.browser.open('http://localhost/app/login') 257 self.browser.getControl(name="form.login").value = 'mrofficer' 258 self.browser.getControl(name="form.password").value = 'mrofficersecret' 259 self.browser.getControl("Login").click() 260 261 self.browser.open(self.datacenter_path + '/export') 262 # The CC Officer can see the accesscodebatches exporter ... 263 self.assertTrue( 264 '<option value="accesscodebatches">' in self.browser.contents) 265 # ... but not the accesscodes exporter. 266 self.assertFalse('<option value="accesscodes">' in self.browser.contents) 267 215 268 def test_export_discard(self): 216 269 # we can discard a generated export result
Note: See TracChangeset for help on using the changeset viewer.