Changeset 2252 in products for quintagroup.seoptimizer/trunk
- Timestamp:
- May 4, 2010 5:07:30 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/tests/testBugs.py
r2249 r2252 102 102 103 103 104 def test_bug_24_at_plone_org(self): 104 class TestBug24AtPloneOrg(FunctionalTestCase): 105 106 def afterSetUp(self): 107 # Add test users: member, editor 105 108 member_id = 'test_member' 106 109 editor_id = 'test_editor' … … 112 115 ['Member','Editor'], []) 113 116 114 member_auth = '%s:%s'%(member_id, test_pswd)115 editor_auth = '%s:%s'%(editor_id, test_pswd)117 self.member_auth = '%s:%s'%(member_id, test_pswd) 118 self.editor_auth = '%s:%s'%(editor_id, test_pswd) 116 119 117 portal_url = '/'.join(self.portal.getPhysicalPath())120 self.portal_url = '/'.join(self.portal.getPhysicalPath()) 118 121 119 resp = self.publish(path=portal_url, basic=member_auth) 122 123 def test_not_break(self): 124 """Default portal page should not breaks for any user""" 125 # Anonymous 126 resp = self.publish(path=self.portal_url) 127 self.assertEqual(resp.getStatus(), 200) 128 # Member 129 resp = self.publish(path=self.portal_url, basic=self.member_auth) 130 self.assertEqual(resp.getStatus(), 200) 131 # Editor: this fails, althought must pass 132 resp = self.publish(path=self.portal_url, basic=self.editor_auth) 120 133 self.assertEqual(resp.getStatus(), 200) 121 134 122 # This fails, althought must pass 123 resp = self.publish(path=portal_url, basic=editor_auth) 124 self.assertEqual(resp.getStatus(), 200) 135 def test_tab_visibility(self): 136 """Only Editor can view seo tab""" 137 rexp = re.compile('<a\s+[^>]*' \ 138 'href="[a-zA-Z0-9\:\/_-]*/@@seo-context-properties"[^>]*>'\ 139 '\s*SEO Properties\s*</a>', re.I|re.S) 140 # Anonymous: NO SEO Properties link 141 res = self.publish(path=self.portal_url).getBody() 142 self.assertEqual(rexp.search(res), None) 143 # Member: NO 'SEO Properties' link 144 res = self.publish(path=self.portal_url, basic=self.member_auth).getBody() 145 self.assertEqual(rexp.search(res), None) 146 # Editor: PRESENT 'SEO Properties' link 147 res = self.publish(path=self.portal_url, basic=self.editor_auth).getBody() 148 self.assertNotEqual(rexp.search(res), None) 125 149 126 def test_seo_context_properties_perms(self): 127 # Anonymous are not allowed to access to @@seo-context-properties 128 self.portal.portal_workflow.doActionFor(self.my_doc, 'publish') 129 resp = self.publish(path=self.mydoc_path+'/@@seo-context-properties') 130 self.assertNotEqual(resp.getStatus(), 200) 150 def test_tab_access(self): 151 """Only Editor can access 'SEO Properties' tab""" 152 test_url = self.portal_url + '/front-page/@@seo-context-properties' 153 # Anonymous: can NOT ACCESS 154 headers = self.publish(path=test_url).headers 155 self.assertEqual( headers.get('bobo-exception-type',""), 'Unauthorized', 156 "No 'Unauthorized' exception rised for Anonymous on '@@seo-context-properties' view") 157 # Member: can NOT ACCESS 158 status = self.publish(path=test_url, basic=self.member_auth).headers 159 self.assertEqual( headers.get('bobo-exception-type',""), 'Unauthorized', 160 "No 'Unauthorized' exception rised for Member on '@@seo-context-properties' view") 161 # Editor: CAN Access 162 res = self.publish(path=test_url, basic=self.editor_auth) 163 self.assertEqual(res.status, 200) 164 165 166 def test_tab_edit(self): 167 """Editor can change SEO Properties""" 168 test_url = self.portal_url + '/front-page/@@seo-context-properties' 169 form_data = {'seo_title': 'New Title', 170 'seo_title_override:int': 1, 171 'form.submitted:int': 1} 172 res = self.publish(path=test_url, basic=self.editor_auth, 173 request_method='POST', stdin=StringIO(urllib.urlencode(form_data))) 174 self.assertNotEqual(res.status, 200) 131 175 132 176 … … 135 179 suite = TestSuite() 136 180 suite.addTest(makeSuite(TestBugs)) 181 suite.addTest(makeSuite(TestBug24AtPloneOrg)) 137 182 return suite 138 183
Note: See TracChangeset
for help on using the changeset viewer.