diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/api/testing.rst | 18 | ||||
| -rw-r--r-- | docs/narr/unittesting.rst | 14 |
2 files changed, 25 insertions, 7 deletions
diff --git a/docs/api/testing.rst b/docs/api/testing.rst index da0a128d9..2b6e1f8ae 100644 --- a/docs/api/testing.rst +++ b/docs/api/testing.rst @@ -5,6 +5,22 @@ .. automodule:: repoze.bfg.testing - .. autoclass:: BFGTestCase + .. autofunction:: registerDummySecurityPolicy + + .. autofunction:: registerModels + + .. autofunction:: registerEventListener + + .. autofunction:: registerTemplateRenderer + + .. autofunction:: registerView + + .. autofunction:: registerViewPermission + + .. autoclass:: DummyModel + :members: + + .. autoclass:: DummyRequest :members: + diff --git a/docs/narr/unittesting.rst b/docs/narr/unittesting.rst index 1e1b23b9f..8e9894c3f 100644 --- a/docs/narr/unittesting.rst +++ b/docs/narr/unittesting.rst @@ -30,10 +30,10 @@ Without invoking any ZCML or using the testing API, an attempt to run this view function will result in an error. When a :mod:`repoze.bfg` application starts normally, it will create an application registry from the information it finds in the application's ``configure.zcml`` -file. If this application registry is not created and populated -(e.g. with ``bfg:view`` statements), such as when you invoke -application code via unit tests, :mod:`repoze.bfg` API functions will -tend to fail. +file. But if this application registry is not created and populated +(e.g. with ``bfg:view`` statements), like when you invoke application +code via a unit test, :mod:`repoze.bfg` API functions will tend to +fail. The testing API provided by ``repoze.bfg`` allows you to simulate various application registry registrations for use under a unit @@ -47,7 +47,7 @@ unittest TestCase that used the testing API. import unittest from zope.testing.cleanup import cleanUp - from.repoze.bfg import testing + from repoze.bfg import testing class MyTest(unittest.TestCase): def setUp(self): @@ -57,13 +57,15 @@ unittest TestCase that used the testing API. cleanUp() def test_view_fn_not_submitted(self): + from my.package import view_fn renderer = testing.registerTemplateRenderer('templates/show.pt') context = testing.DummyModel() request = testing.DummyRequest() response = view_fn(context, request) self.assertEqual(renderer.say, 'Hello') - def test_view_fn_submitted(self): + def test_view_fn_submitted(self): + from my.package import view_fn renderer = testing.registerTemplateRenderer('templates/submitted.pt') context = testing.DummyModel() request = testing.DummyRequest() |
