[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - test_configurationregistry.py:1.9

Guido van Rossum guido@python.org
Wed, 18 Jun 2003 16:12:12 -0400


Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv21151/services/tests

Modified Files:
	test_configurationregistry.py 
Log Message:
A major change in the semantics of the ConfigurationRegistry class
(and its interface).  When you deactivate an entry, the next entry is
activated.  A None entry may occur (once) at any position.  The info()
method now has an optional keep_dummy argument, which, when True,
returns an info entry corresponding to the dummy None in the data.

This is done so that uninstalling a bundle has a more natural effect:
all the activations that were overridden by the bundle are reactivated
when the bundle is uninstalled.

It is possible that this breaks part of the UI; I've fixed the only
place in the UI that I'm aware of that uses this, the code for
activating services; but there may be other places.


=== Zope3/src/zope/app/services/tests/test_configurationregistry.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/services/tests/test_configurationregistry.py:1.8	Tue Jun  3 18:46:22 2003
+++ Zope3/src/zope/app/services/tests/test_configurationregistry.py	Wed Jun 18 16:12:11 2003
@@ -118,6 +118,21 @@
         self.failUnless(registry.registered(c2))
         self.assertEqual(registry.active(), c1)
 
+    def test_activate_none(self):
+        self.test_activate_and_active()
+
+        registry = self.__registry
+        c1 = self.__c1
+        c2 = self.__c2
+
+        registry.activate(None)
+
+        self.assertEqual(c1.active, 0)
+        self.failUnless(registry.registered(c1))
+        self.assertEqual(c2.active, 0)
+        self.failUnless(registry.registered(c2))
+        self.assertEqual(registry.active(), None)
+
     def test_activate_unregistered(self):
         registry = self.__registry
         self.assertRaises(ValueError, registry.activate, self.__config('3'))
@@ -137,9 +152,9 @@
         self.assertEqual(registry.active(), c1)
 
         registry.deactivate(c1)
-        self.assertEqual(c2.active, 0)
         self.assertEqual(c1.active, 0)
-        self.assertEqual(registry.active(), None)
+        self.assertEqual(c2.active, 1)
+        self.assertEqual(registry.active(), c2)
 
         self.failUnless(registry.registered(c1))
         self.failUnless(registry.registered(c2))
@@ -153,9 +168,9 @@
         self.assertEqual(registry.active(), c1)
 
         registry.unregister(c1)
-        self.assertEqual(c2.active, 0)
         self.assertEqual(c1.active, 0)
-        self.assertEqual(registry.active(), None)
+        self.assertEqual(c2.active, 1)
+        self.assertEqual(registry.active(), c2)
 
         self.failIf(registry.registered(c1))
         self.failUnless(registry.registered(c2))
@@ -172,7 +187,6 @@
         c2 = self.__c2
 
         info = registry.info()
-        info.sort(lambda a, b: cmp(a['id'], b['id']))
         self.assertEqual(
             info,
             [
@@ -189,17 +203,34 @@
         registry.deactivate(c1)
 
         info = registry.info()
-        info.sort(lambda a, b: cmp(a['id'], b['id']))
         self.assertEqual(
             info,
             [
+              {'id': 'default/2',
+               'active': True,
+               'configuration': c2,
+               },
               {'id': 'default/1',
                'active': False,
                'configuration': c1,
                },
+              ])
+
+        info = registry.info(True)
+        self.assertEqual(
+            info,
+            [
               {'id': 'default/2',
-               'active': False,
+               'active': True,
                'configuration': c2,
+               },
+              {'id': '',
+               'active': False,
+               'configuration': None,
+               },
+              {'id': 'default/1',
+               'active': False,
+               'configuration': c1,
                },
               ])