[Zope3-checkins] CVS: Zope3/src/zope/app/apidoc/ifacemodule -
ftests.py:1.1 tests.py:1.4
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sun Mar 28 18:40:53 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/apidoc/ifacemodule
In directory cvs.zope.org:/tmp/cvs-serv22726/src/zope/app/apidoc/ifacemodule
Modified Files:
tests.py
Added Files:
ftests.py
Log Message:
Added tests.
=== Added File Zope3/src/zope/app/apidoc/ifacemodule/ftests.py ===
##############################################################################
#
# Copyright (c) 2003, 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Functional Tests for Interface Documentation Module.
$Id: ftests.py,v 1.1 2004/03/28 23:40:52 srichter Exp $
"""
import unittest
from zope.testing.functional import BrowserTestCase
class InterfaceModuleTests(BrowserTestCase):
"""Just a couple of tests ensuring that the templates render."""
def testMenu(self):
response = self.publish(
'/++apidoc++/Interface/menu.html',
basic='mgr:mgrpw')
self.assertEqual(response.getStatus(), 200)
body = response.getBody()
self.assert_(body.find(
'zope.app.apidoc.ifacemodule.IInterfaceModule') > 0)
self.checkForBrokenLinks(body, '/++apidoc++/Interface/menu.html',
basic='mgr:mgrpw')
def testInterfaceDetailsView(self):
response = self.publish(
'/++apidoc++/Interface'
'/zope.app.apidoc.ifacemodule.IInterfaceModule'
'/apiindex.html',
basic='mgr:mgrpw')
self.assertEqual(response.getStatus(), 200)
body = response.getBody()
self.assert_(body.find('Interface API Documentation Module') > 0)
self.checkForBrokenLinks(
body,
'/++apidoc++/Interface'
'/zope.app.apidoc.ifacemodule.IInterfaceModule'
'/apiindex.html',
basic='mgr:mgrpw')
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(InterfaceModuleTests),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/apidoc/ifacemodule/tests.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/apidoc/ifacemodule/tests.py:1.3 Sat Mar 13 16:03:01 2004
+++ Zope3/src/zope/app/apidoc/ifacemodule/tests.py Sun Mar 28 18:40:52 2004
@@ -16,23 +16,30 @@
$Id$
"""
import unittest
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.app.location import LocationProxy
-from zope.app.tests import placelesssetup
-from zope.interface import implements
-from zope.app.apidoc.ifacemodule import IInterfaceModule
-from zope.app.apidoc.interfaces import IDocumentationModule
+from zope.component.interfaces import IFactory
+from zope.component.factory import Factory
+from zope.interface import implements, Interface, Attribute
+from zope.interface.interfaces import IInterface
+from zope.publisher.browser import TestRequest
+from zope.schema import TextLine, Text
from zope.testing.doctestunit import DocTestSuite
+from zope.app import zapi
from zope.app.component.interface import provideInterface
+from zope.app.location import LocationProxy
+from zope.app.tests import placelesssetup, ztapi
+from zope.app.traversing.interfaces import IContainmentRoot
+from zope.app.tree.interfaces import IUniqueId
+from zope.app.tree.adapters import LocationUniqueId
-def setUp():
- placelesssetup.setUp()
- provideInterface(None, IDocumentationModule)
- provideInterface('IInterfaceModule', IInterfaceModule)
+from zope.app.traversing.interfaces import IPhysicallyLocatable
+from zope.app.location import LocationPhysicallyLocatable, LocationProxy
-def tearDown():
- placelesssetup.tearDown()
+from zope.app.apidoc.classmodule import classRegistry
+from zope.app.apidoc.ifacemodule import IInterfaceModule, InterfaceModule
+from zope.app.apidoc.ifacemodule.menu import IModule
+from zope.app.apidoc.ifacemodule.browser import InterfaceDetails
+from zope.app.apidoc.interfaces import IDocumentationModule
class Root:
@@ -43,11 +50,73 @@
def rootLocation(obj, name):
return LocationProxy(obj, Root(), name)
+
+class IFoo(Interface):
+ """This is the Foo interface
+
+ More description here...
+ """
+ foo = Attribute('This is foo.')
+ bar = Attribute('This is bar.')
+
+ title = TextLine(description=u'Title', required=True, default=u'Foo')
+ description = Text(description=u'Desc', required=False, default=u'Foo.')
+
+ def blah():
+ """This is blah."""
+
+ def get(key, default=None):
+ """This is get."""
+
+class IBar(Interface):
+ pass
+
+class Foo:
+ implements(IFoo)
+
+
+def getInterfaceDetails():
+ ifacemodule = InterfaceModule()
+ ifacemodule.__parent__ = Root()
+ ifacemodule.__name__ = 'Interfaces'
+ iface = LocationProxy(IFoo, ifacemodule, 'IFoo')
+ view = InterfaceDetails()
+ view.context = iface
+ view.request = TestRequest()
+ return view
+
+
+def setUp():
+ placelesssetup.setUp()
+ provideInterface(None, IDocumentationModule)
+ provideInterface('IInterfaceModule', IInterfaceModule)
+ ztapi.provideAdapter(IInterface, IUniqueId, LocationUniqueId)
+ ztapi.provideAdapter(None, IPhysicallyLocatable,
+ LocationPhysicallyLocatable)
+
+ # Make IFoo adapter interesting.
+
+ ztapi.provideAdapter(IBar, IFoo, object)
+ classRegistry[Foo.__module__ + '.' + Foo.__name__] = Foo
+ ztapi.provideUtility(IFactory, Factory(Foo, title='Foo Factory'),
+ 'FooFactory')
+ ztapi.provideUtility(IFoo, Foo(), 'The Foo')
+ sm = zapi.getService(None, 'Services')
+ sm.defineService('Foo', IFoo)
+ sm.provideService('Foo', Foo())
+
+def tearDown():
+ placelesssetup.tearDown()
+ del classRegistry[Foo.__module__ + '.' + Foo.__name__]
def test_suite():
return unittest.TestSuite((
- DocTestSuite('zope.app.apidoc.ifacemodule'),
- DocTestSuite('zope.app.apidoc.ifacemodule.menu'),
+ DocTestSuite('zope.app.apidoc.ifacemodule',
+ setUp=setUp, tearDown=tearDown),
+ DocTestSuite('zope.app.apidoc.ifacemodule.menu',
+ setUp=setUp, tearDown=tearDown),
+ DocTestSuite('zope.app.apidoc.ifacemodule.browser',
+ setUp=setUp, tearDown=tearDown),
))
if __name__ == '__main__':
More information about the Zope3-Checkins
mailing list