Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
pyramid.pdf
Скачиваний:
10
Добавлен:
24.03.2015
Размер:
3.82 Mб
Скачать

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.

436

36.8. ADDING TESTS

1

2

3

4

5

6

7

8

9

10

requires = [ ’pyramid’,

’pyramid_zodbconn’, ’pyramid_tm’, ’pyramid_debugtoolbar’, ’ZODB3’,

’waitress’, ’docutils’, ’WebTest’, # add this

]

After we’ve added a dependency on WebTest in setup.py, we need to rerun setup.py develop to get WebTest installed into our virtualenv. Assuming our shell’s current working directory is the “tutorial” distribution directory:

On UNIX:

$ ../bin/python setup.py develop

On Windows:

c:\pyramidtut\tutorial> ..\Scripts\python setup.py develop

Once that command has completed successfully, we can run the tests themselves: On UNIX:

$ ../bin/python setup.py test -q

On Windows:

c:\pyramidtut\tutorial> ..\Scripts\python setup.py test -q

The expected result looks something like:

.........

----------------------------------------------------------------------

Ran 23 tests in 1.653s

OK

437

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]