[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZMI/tests - testServiceProvideClass.py:1.1.2.1 testProvideClass.py:1.1.2.2
Scott Robertson
srobertson@codeit.com
Sat, 9 Feb 2002 12:43:31 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZMI/tests
In directory cvs.zope.org:/tmp/cvs-serv2438/lib/python/Zope/App/ZMI/tests
Modified Files:
Tag: Zope-3x-branch
testProvideClass.py
Added Files:
Tag: Zope-3x-branch
testServiceProvideClass.py
Log Message:
Refactored provideClass to use different addable registries.
Fixed the tests that called provied class to pass in the appropriate
registry as needed (either ContentAddables or ServiceAddables).
Modified zope.zcml to use the new "service" namespace which provides the
provideClass directive for services.
=== Added File Zope3/lib/python/Zope/App/ZMI/tests/testServiceProvideClass.py ===
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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.
""" ZMI unit tests """
import unittest, sys, Interface
from Zope.App.ZMI.Addable import ServiceAddables
from Zope.App.ZMI import provideClass
class MyAddableService:
pass
class ServiceProvideClassTest(unittest.TestCase):
def setUp(self):
ServiceAddables._clear()
def tearDown(self):
from Zope.App.ZMI.Addable import _clear
_clear()
from Zope.ComponentArchitecture import _clear
_clear()
def testProvideClass(self):
from Zope.ComponentArchitecture.hooks import createObject
provideClass(ServiceAddables, 'My.Test.Addable', MyAddableService, None, 'Testing')
object = createObject(None,'My.Test.Addable')
self.assert_(isinstance(object, MyAddableService))
def testGetAddables(self):
provideClass(ServiceAddables, 'My.Test.Addable', MyAddableService, None, 'Testing')
addables = ServiceAddables.getAddables(None)
self.assertEqual(addables[0].id,'My.Test.Addable')
def test_suite():
loader = unittest.TestLoader()
return loader.loadTestsFromTestCase(ServiceProvideClassTest)
if __name__ == '__main__':
unittest.TextTestRunner().run(test_suite())
=== Zope3/lib/python/Zope/App/ZMI/tests/testProvideClass.py 1.1.2.1 => 1.1.2.2 ===
from Zope.ComponentArchitecture.hooks import createObject
from Zope.App.ZMI import provideClass
+ from Zope.App.ZMI.Addable import ContentAddables
- provideClass('My.Test.Addable', MyAddableObject, None, 'Testing')
+ provideClass(ContentAddables, 'My.Test.Addable', MyAddableObject, None, 'Testing')
object = createObject(None,'My.Test.Addable')
self.assert_(isinstance(object, MyAddableObject))