Changeset 12072 for main/waeup.ikoba/trunk
- Timestamp:
- 27 Nov 2014, 17:08:19 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/permissions.py
r12068 r12072 92 92 grok.permissions('waeup.viewProducts') 93 93 94 class Products sManager(grok.Role):94 class ProductsManager(grok.Role): 95 95 grok.name('waeup.ProductsManager') 96 96 grok.title(u'Products Manager') -
main/waeup.ikoba/trunk/src/waeup/ikoba/products/browser.py
r12068 r12072 99 99 type='danger') 100 100 return 101 delSubobjects(self, redirect=' @@manage', tab='2')101 delSubobjects(self, redirect='manage', tab='2') 102 102 return 103 103 … … 113 113 @action(_('Add product'), validator=NullValidator) 114 114 def addSubunit(self, **data): 115 self.redirect(self.url(self.context, ' @@addproduct'))115 self.redirect(self.url(self.context, 'addproduct')) 116 116 return 117 117 … … 142 142 self.context.__parent__.logger.info( 143 143 '%s - added: %s' % (ob_class, data['product_id'])) 144 self.redirect(self.url(self.context, u' @@manage')+'#tab2')144 self.redirect(self.url(self.context, u'manage')+'#tab2') 145 145 return 146 146 -
main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_browser.py
r12069 r12072 84 84 setSite(app) 85 85 86 87 self.login_path = 'http://localhost/app/login' 88 86 # Add user 87 self.app['users'].addUser(name='john', password='johnpwd', 88 title='John Tester', 89 email='john@tester.de') 90 91 # Add some product 92 self.product = createObject('waeup.Product') 93 self.product.product_id = u'LIC' 94 self.product.title = u'Our License' 95 self.app['products'].addProduct(self.product) 96 97 # Add session configuration 89 98 self.app['configuration'].carry_over = True 90 99 configuration = createObject('waeup.SessionConfiguration') 100 91 101 self.app['configuration'].addSessionConfiguration(configuration) 102 self.login_path = 'http://localhost/app/login' 103 self.container_path = 'http://localhost/app/products' 104 self.manage_container_path = self.container_path + '/manage' 105 self.add_product_path = self.container_path + '/addproduct' 106 self.product_path = self.container_path + '/LIC' 107 self.manage_product_path = self.container_path + '/LIC/manage' 92 108 93 109 # Put the prepopulated site into test ZODB and prepare test … … 97 113 98 114 def tearDown(self): 99 super( CustomersFullSetup, self).tearDown()115 super(ProductssFullSetup, self).tearDown() 100 116 clearSite() 101 117 shutil.rmtree(self.dc_root) 118 119 class ProductsContainerUITests(ProductssFullSetup): 120 # Tests for ProductsContainer class views and pages 121 122 layer = FunctionalLayer 123 124 def test_anonymous_access(self): 125 # Anonymous users can view products containers ... 126 self.browser.open(self.container_path) 127 self.assertEqual(self.browser.headers['Status'], '200 Ok') 128 # ... but not manage 129 self.assertRaises( 130 Unauthorized, self.browser.open, self.manage_container_path) 131 return 132 133 def test_manage_access(self): 134 # Managers can access the view page of products 135 # containers and can perform actions 136 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 137 self.browser.open(self.container_path) 138 self.assertEqual(self.browser.headers['Status'], '200 Ok') 139 self.assertEqual(self.browser.url, self.container_path) 140 self.browser.getLink("Manage").click() 141 self.assertEqual(self.browser.headers['Status'], '200 Ok') 142 self.assertEqual(self.browser.url, self.manage_container_path) 143 return 144 145 def test_add_delete_products(self): 146 # Managers can add search and remove products 147 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 148 self.browser.open(self.manage_container_path) 149 self.browser.getControl("Add product").click() 150 self.assertEqual(self.browser.headers['Status'], '200 Ok') 151 self.assertEqual(self.browser.url, self.add_product_path) 152 self.browser.getControl(name="form.product_id").value = 'bob' 153 self.browser.getControl(name="form.title").value = 'My product' 154 self.browser.getControl("Create product").click() 155 self.assertTrue('Product bob added' in self.browser.contents) 156 self.assertEqual(len(self.app['products'].keys()), 2) 157 self.assertEqual(self.app['products']['bob'].title, 'My product') 158 ctrl = self.browser.getControl(name='val_id') 159 ctrl.getControl(value='bob').selected = True 160 self.browser.getControl("Remove selected", index=0).click() 161 self.assertTrue('Successfully removed' in self.browser.contents) 162 self.assertEqual(len(self.app['products'].keys()), 1) 163 164 165 class ProductsUITests(ProductssFullSetup): 166 # Tests for Products class views and pages 167 168 layer = FunctionalLayer 169 170 def test_anonymous_access(self): 171 # Anonymous users can access products ... 172 self.browser.open(self.product_path) 173 self.assertEqual(self.browser.headers['Status'], '200 Ok') 174 # ... but not manage products 175 self.assertRaises( 176 Unauthorized, self.browser.open, self.manage_product_path) 177 return 178 179 def test_manage_access(self): 180 # Managers can access the view page of products 181 # and can perform actions 182 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 183 self.browser.open(self.product_path) 184 self.assertEqual(self.browser.headers['Status'], '200 Ok') 185 self.browser.getLink("Manage").click() 186 self.assertEqual(self.browser.headers['Status'], '200 Ok') 187 self.assertEqual(self.browser.url, self.manage_product_path) 188 self.browser.getControl(name="form.title").value = 'New license' 189 self.browser.getControl("Save").click() 190 self.assertEqual(self.app['products']['LIC'].title, 'New license') 191 # Managers can asign local roles 192 self.browser.getControl(name="user").value = ['john'] 193 self.browser.getControl( 194 name="local_role").value = ['waeup.local.ProductManager'] 195 self.browser.getControl("Add local role").click() 196 self.assertTrue('john|waeup.local.ProductManager' in self.browser.contents) 197 self.assertEqual( 198 self.app['users']['john'].getLocalRoles().get( 199 'waeup.local.ProductManager')[0], 200 self.product) 201 # If products is deleted also the local role disappears 202 self.browser.open(self.manage_container_path) 203 ctrl = self.browser.getControl(name='val_id') 204 ctrl.getControl(value='LIC').selected = True 205 self.browser.getControl("Remove selected", index=0).click() 206 self.assertEqual( 207 self.app['users']['john'].getLocalRoles().get('waeup.local.ProductManager'), 208 None) 209 return
Note: See TracChangeset for help on using the changeset viewer.