36. ZODB + TRAVERSAL WIKI TUTORIAL
181res = self.testapp.get(’/FrontPage’, status=200)
182res = self.testapp.get(’/logout’, status=302)
183self.assertTrue(’Logout’ not in res.body)
184
185def test_anonymous_user_cannot_edit(self):
186res = self.testapp.get(’/FrontPage/edit_page’, status=200)
187self.assertTrue(’Login’ in res.body)
188
189def test_anonymous_user_cannot_add(self):
190res = self.testapp.get(’/add_page/NewPage’, status=200)
191self.assertTrue(’Login’ in res.body)
192
193def test_viewer_user_cannot_edit(self):
194res = self.testapp.get( self.viewer_login, status=302)
195res = self.testapp.get(’/FrontPage/edit_page’, status=200)
196self.assertTrue(’Login’ in res.body)
197
198def test_viewer_user_cannot_add(self):
199res = self.testapp.get( self.viewer_login, status=302)
200res = self.testapp.get(’/add_page/NewPage’, status=200)
201self.assertTrue(’Login’ in res.body)
202
203def test_editors_member_user_can_edit(self):
204res = self.testapp.get( self.editor_login, status=302)
205res = self.testapp.get(’/FrontPage/edit_page’, status=200)
206self.assertTrue(’Editing’ in res.body)
207
208def test_editors_member_user_can_add(self):
209res = self.testapp.get( self.editor_login, status=302)
210res = self.testapp.get(’/add_page/NewPage’, status=200)
211self.assertTrue(’Editing’ in res.body)
212
213def test_editors_member_user_can_view(self):
214res = self.testapp.get( self.editor_login, status=302)
215res = self.testapp.get(’/FrontPage’, status=200)
216self.assertTrue(’FrontPage’ in res.body)
36.8.5Run the Tests
We can run these tests by using setup.py test in the same way we did in Run the Tests. However, first we must edit our setup.py to include a dependency on WebTest, which we’ve used in our tests.py. Change the requires list in setup.py to include WebTest.