diff options
Diffstat (limited to 'docs/tutorials/bfgwiki/src/basiclayout')
3 files changed, 4 insertions, 69 deletions
diff --git a/docs/tutorials/bfgwiki/src/basiclayout/tutorial/configure.zcml b/docs/tutorials/bfgwiki/src/basiclayout/tutorial/configure.zcml index f990298c5..e15d3a65d 100644 --- a/docs/tutorials/bfgwiki/src/basiclayout/tutorial/configure.zcml +++ b/docs/tutorials/bfgwiki/src/basiclayout/tutorial/configure.zcml @@ -6,6 +6,7 @@ <view for=".models.MyModel" view=".views.my_view" + renderer="templates/mytemplate.pt" /> <static diff --git a/docs/tutorials/bfgwiki/src/basiclayout/tutorial/tests.py b/docs/tutorials/bfgwiki/src/basiclayout/tutorial/tests.py index 408645fcb..f8c0ceb20 100644 --- a/docs/tutorials/bfgwiki/src/basiclayout/tutorial/tests.py +++ b/docs/tutorials/bfgwiki/src/basiclayout/tutorial/tests.py @@ -3,71 +3,9 @@ import unittest from repoze.bfg import testing class ViewTests(unittest.TestCase): - - """ These tests are unit tests for the view. They test the - functionality of *only* the view. They register and use dummy - implementations of repoze.bfg functionality to allow you to avoid - testing 'too much'""" - - def setUp(self): - """ cleanUp() is required to clear out the application registry - between tests (done in setUp for good measure too) - """ - testing.cleanUp() - - def tearDown(self): - """ cleanUp() is required to clear out the application registry - between tests - """ - testing.cleanUp() - def test_my_view(self): from tutorial.views import my_view context = testing.DummyModel() request = testing.DummyRequest() - renderer = testing.registerDummyRenderer('templates/mytemplate.pt') - response = my_view(context, request) - renderer.assert_(project='tutorial') - -class ViewIntegrationTests(unittest.TestCase): - """ These tests are integration tests for the view. These test - the functionality the view *and* its integration with the rest of - the repoze.bfg framework. They cause the entire environment to be - set up and torn down as if your application was running 'for - real'. This is a heavy-hammer way of making sure that your tests - have enough context to run properly, and it tests your view's - integration with the rest of BFG. You should not use this style - of test to perform 'true' unit testing as tests will run faster - and will be easier to write if you use the testing facilities - provided by bfg and only the registrations you need, as in the - above ViewTests. - """ - def setUp(self): - """ This sets up the application registry with the - registrations your application declares in its configure.zcml - (including dependent registrations for repoze.bfg itself). - """ - testing.cleanUp() - import tutorial - import zope.configuration.xmlconfig - zope.configuration.xmlconfig.file('configure.zcml', - package=tutorial) - - def tearDown(self): - """ Clear out the application registry """ - testing.cleanUp() - - def test_my_view(self): - from tutorial.views import my_view - context = testing.DummyModel() - request = testing.DummyRequest() - result = my_view(context, request) - self.assertEqual(result.status, '200 OK') - body = result.app_iter[0] - self.failUnless('Welcome to' in body) - self.assertEqual(len(result.headerlist), 2) - self.assertEqual(result.headerlist[0], - ('Content-Type', 'text/html; charset=UTF-8')) - self.assertEqual(result.headerlist[1], ('Content-Length', - str(len(body)))) - + info = my_view(context, request) + self.assertEqual(info['project'], 'tutorial') diff --git a/docs/tutorials/bfgwiki/src/basiclayout/tutorial/views.py b/docs/tutorials/bfgwiki/src/basiclayout/tutorial/views.py index 923c1fffa..9a2c37bc3 100644 --- a/docs/tutorials/bfgwiki/src/basiclayout/tutorial/views.py +++ b/docs/tutorials/bfgwiki/src/basiclayout/tutorial/views.py @@ -1,6 +1,2 @@ -from repoze.bfg.chameleon_zpt import render_template_to_response - def my_view(context, request): - return render_template_to_response('templates/mytemplate.pt', - request = request, - project = 'tutorial') + return {'project':'tutorial'} |
