[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests - testConfigurationManager.py:1.2.10.1
Marius Gedminas
mgedmin@codeworks.lt
Wed, 11 Dec 2002 10:14:04 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests
In directory cvs.zope.org:/tmp/cvs-serv22255/lib/python/Zope/App/OFS/Services/ServiceManager/tests
Modified Files:
Tag: named-component-configuration-branch
testConfigurationManager.py
Log Message:
Bugfix: it used to be possible to delete a ConfigurationManager with active
or registered configurations without unregistering them
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testConfigurationManager.py 1.2 => 1.2.10.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testConfigurationManager.py:1.2 Sat Nov 30 13:39:18 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testConfigurationManager.py Wed Dec 11 10:14:04 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 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$
@@ -22,12 +22,28 @@
from unittest import TestCase, TestSuite, main, makeSuite
from Interface.Common.tests.BaseTestMapping import BaseTestIEnumerableMapping
from Interface.Verify import verifyObject
+from Zope.App.OFS.Container.IDeleteNotifiable import IDeleteNotifiable
+from Zope.App.OFS.Container.IContainer import IContainer
+from Zope.App.OFS.Container.IZopeContainer import IZopeContainer
+from Zope.App.OFS.Container.ZopeContainerAdapter import ZopeContainerAdapter
+from Zope.App.tests.PlacelessSetup import PlacelessSetup
+from Zope.ComponentArchitecture.GlobalAdapterService import provideAdapter
-class Test(BaseTestIEnumerableMapping, TestCase):
+
+class Undeletable:
+
+ __implements__ = IDeleteNotifiable
+
+ def manage_beforeDelete(self, object, container):
+ self.was_called = 1
+
+
+class Test(BaseTestIEnumerableMapping, PlacelessSetup, TestCase):
"""Testing for Configuration Manager """
def setUp(self):
+ PlacelessSetup.setUp(self)
self.__manager = manager = ConfigurationManager()
for l in 'abcdefghijklmnop':
manager.setObject('', l)
@@ -36,7 +52,7 @@
def test_implements_IConfigurationManager(self):
verifyObject(IConfigurationManager, self.__manager)
-
+
def _IEnumerableMapping__stateDict(self):
# Hook needed by BaseTestIEnumerableMapping
# also, effectively test setObject and __delitem__.
@@ -63,10 +79,10 @@
self.__manager.moveTop([])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -74,10 +90,10 @@
self.__manager.moveTop(['1'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -85,10 +101,10 @@
self.__manager.moveTop(['1', '88', '3', '2', '99'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -96,10 +112,10 @@
self.__manager.moveTop(['3'])
self.assertEqual(
list(self.__manager.keys()),
- ['3', '1', '2', '4', '5', '6', '7', '9',
+ ['3', '1', '2', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -107,10 +123,10 @@
self.__manager.moveTop(['1', '3', '88', '4', '11', '15', '16', '99'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '3', '4', '11', '15', '16', '2', '5', '6', '7', '9',
+ ['1', '3', '4', '11', '15', '16', '2', '5', '6', '7', '9',
'12', '13', '14'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -119,7 +135,7 @@
manager.setObject('', 'a')
manager.moveTop(['1'])
self.assertEqual(list(manager.items()), [('1', 'a')])
-
+
#########################################################
# Move Bottom
@@ -127,10 +143,10 @@
self.__manager.moveBottom([])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -138,10 +154,10 @@
self.__manager.moveBottom(['16'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -149,10 +165,10 @@
self.__manager.moveBottom(['14', '88', '16', '15', '99'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -160,10 +176,10 @@
self.__manager.moveBottom(['3'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '4', '5', '6', '7', '9',
+ ['1', '2', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16', '3'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -172,10 +188,10 @@
['1', '3', '88', '4', '11', '16', '15', '99'])
self.assertEqual(
list(self.__manager.keys()),
- ['2', '5', '6', '7', '9',
+ ['2', '5', '6', '7', '9',
'12', '13', '14', '1', '3', '4', '11', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -184,18 +200,18 @@
manager.setObject('', 'a')
manager.moveBottom(['1'])
self.assertEqual(list(manager.items()), [('1', 'a')])
-
+
#########################################################
# Move Up
-
+
def test_moveUp_nothing(self):
self.__manager.moveUp([])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -203,10 +219,10 @@
self.__manager.moveUp(['1'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -214,10 +230,10 @@
self.__manager.moveUp(['1', '88', '3', '2', '99'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -225,10 +241,10 @@
self.__manager.moveUp(['3'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '3', '2', '4', '5', '6', '7', '9',
+ ['1', '3', '2', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -237,10 +253,10 @@
['1', '3', '88', '4', '11', '16', '15', '99'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '3', '4', '2', '5', '6', '7', '11', '9',
+ ['1', '3', '4', '2', '5', '6', '7', '11', '9',
'12', '13', '15', '16', '14'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -249,18 +265,18 @@
manager.setObject('', 'a')
manager.moveUp(['1'])
self.assertEqual(list(manager.items()), [('1', 'a')])
-
+
#########################################################
# Move Down
-
+
def test_moveDown_nothing(self):
self.__manager.moveDown([])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -268,10 +284,10 @@
self.__manager.moveDown(['16'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -279,10 +295,10 @@
self.__manager.moveDown(['16', '88', '14', '15', '99'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '3', '4', '5', '6', '7', '9',
+ ['1', '2', '3', '4', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -290,10 +306,10 @@
self.__manager.moveDown(['3'])
self.assertEqual(
list(self.__manager.keys()),
- ['1', '2', '4', '3', '5', '6', '7', '9',
+ ['1', '2', '4', '3', '5', '6', '7', '9',
'11', '12', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -302,10 +318,10 @@
['1', '3', '88', '4', '11', '16', '15', '99'])
self.assertEqual(
list(self.__manager.keys()),
- ['2', '1', '5', '3', '4', '6', '7', '9',
+ ['2', '1', '5', '3', '4', '6', '7', '9',
'12', '11', '13', '14', '15', '16'],
)
-
+
# Make sure we still have thye right items
self.test_items()
@@ -314,9 +330,18 @@
manager.setObject('', 'a')
manager.moveDown(['1'])
self.assertEqual(list(manager.items()), [('1', 'a')])
-
-
-
+
+ #########################################################
+
+ def test_manageBeforeDelete(self):
+ provideAdapter(IContainer, IZopeContainer, ZopeContainerAdapter)
+ container = []
+ manager = ConfigurationManager()
+ thingy = Undeletable()
+ manager.setObject('xyzzy', thingy)
+ manager.manage_beforeDelete(manager, container)
+ self.failUnless(thingy.was_called)
+
def test_suite():
return makeSuite(Test)