On Mon, 2005-10-17 at 20:37 +0100, pete wrote:
> Hi,
> I've been looking at making a view class for the RSS syndication in 
> CMFDefault, and I've got all the forms and templates working fine.  So 
> now it's on to testing!
> Has anyone written many tests for a view class?  I'm not quite sure how 
> to set the tests up, i.e. put the request and context in the right 
> place.  If there is an example floating round, please point me in the 
> right direction!

All the tests I've written in this vein have been for a non-OSS customer
project and thus are not shareable, but usually it's enough to make a
"dummy" context (any instance) and pass it in to the view class as the
first argument.  If your view relies on attributes or methods of the
context instance, give those to your dummy class.  Pass an empty
dictionary in as the request object.  If your view uses the RESPONSE
object of the REQUEST, create a dummy one of those too and put it in the
dictionary.  If your view uses adapters, have your test case subclass
the PlacelessSetup class (from zope.app.tests.placelesssetup import
PlacelessSetup) along with unittest.TestCase; you should be able to use
ztapi.provideAdapter then to set up "dummy" adapters.

Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to