[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/RoleService/Views/Browser/tests - __init__.py:1.2 testAdder.py:1.2 testContents.py:1.2
Jim Fulton
jim@zope.com
Mon, 10 Jun 2002 19:28:43 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/RoleService/Views/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/Zope/App/OFS/Services/RoleService/Views/Browser/tests
Added Files:
__init__.py testAdder.py testContents.py
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.
=== Zope3/lib/python/Zope/App/OFS/Services/RoleService/Views/Browser/tests/__init__.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 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.
+#
+##############################################################################
+
=== Zope3/lib/python/Zope/App/OFS/Services/RoleService/Views/Browser/tests/testAdder.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 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.
+#
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+
+from unittest import TestCase, TestSuite, main, makeSuite
+from Zope.ComponentArchitecture import getService
+from Zope.ComponentArchitecture.IFactory import IFactory
+from Zope.App.OFS.Container.Exceptions import DuplicateIDError
+from Zope.App.OFS.Services.ServiceManager.tests.PlacefulSetup import PlacefulSetup
+
+class Role(object):
+ __class_implements__ = IFactory
+
+ def setId(self, id):
+ self.id = id
+
+
+ def getInterfaces():
+ """Dummy stub."""
+ pass
+
+ def __call__():
+ """A factory should always be callable."""
+ pass
+
+
+class Test(PlacefulSetup, TestCase):
+ """Base adding tests
+
+ Subclasses need to define a method, '_TestView__newContext', that
+ takes no arguments and that returns a new test view context.
+
+ Subclasses need to define a method, '_TestView__newView', that
+ takes a context object and that returns a new test view.
+
+ Subclasses need to define a method, '_TestAdderView__registry', that
+ returns the appropriate registry.
+
+ """
+
+ def setUp(self):
+ PlacefulSetup.setUp(self)
+ getService(None,'Factories').provideFactory(
+ "Zope.App.OFS.Services.RoleService.Role.", Role)
+
+ def _TestView__newContext(self):
+ from Zope.App.OFS.Services.RoleService.RoleService import RoleService
+ return RoleService()
+
+ def _TestView__newView(self, container):
+ from Zope.App.OFS.Services.RoleService.Views.Browser.Adder import Adder
+ return Adder(container, None)
+
+
+ def testAdding(self):
+ """
+ Does addition of a new object with the same ID as an existing
+ object fail?
+ """
+ container = self._TestView__newContext()
+ fa = self._TestView__newView( container )
+ fa.action(id='foo' )
+
+ self.assertEquals(len(container.keys()), 1)
+ self.assertEquals(container.keys()[0], 'foo')
+ self.assertEquals(len(container.values()), 1)
+ self.assertEquals(container.values()[0].__class__, Role)
+
+ def testDuplicates( self ):
+ """
+ Does addition of a new object with the same ID as an existing
+ object fail?
+ """
+ container = self._TestView__newContext()
+ fa = self._TestView__newView(container)
+ fa.action(id='foo')
+
+ self.assertRaises(DuplicateIDError, fa.action, id='foo')
+
+def test_suite():
+ return TestSuite([makeSuite(Test)])
+
+if __name__=='__main__':
+ main(defaultTest='test_suite')
=== Zope3/lib/python/Zope/App/OFS/Services/RoleService/Views/Browser/tests/testContents.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+import unittest
+
+from Interface import Interface
+from Zope.App.OFS.Services.RoleService.Views.Browser.Contents import Contents
+from Zope.App.OFS.Services.RoleService.RoleService import RoleService
+from Zope.App.OFS.Container.Views.Browser.tests.testContents \
+ import BaseTestContentsBrowserView
+
+class IDummy(Interface):
+ pass
+
+class Dummy:
+ __implements__ = IDummy
+
+class Test(BaseTestContentsBrowserView, unittest.TestCase):
+
+ def _TestView__newContext(self):
+ return RoleService()
+
+ def _TestView__newView(self, container):
+ return Contents(container, None)
+
+def test_suite():
+ loader = unittest.TestLoader()
+ return loader.loadTestsFromTestCase( Test )
+
+if __name__=='__main__':
+ unittest.main()