[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/tests - testNameConfigurable.py:1.3

Marius Gedminas mgedmin@codeworks.lt
Thu, 12 Dec 2002 10:28:19 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/tests
In directory cvs.zope.org:/tmp/cvs-serv24277/lib/python/Zope/App/OFS/Services/tests

Modified Files:
	testNameConfigurable.py 
Log Message:
Caching service now uses the new configuration infrastructure
Added invalidateAll to Zope.App.Caching.ICache



=== Zope3/lib/python/Zope/App/OFS/Services/tests/testNameConfigurable.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/OFS/Services/tests/testNameConfigurable.py:1.2	Thu Dec 12 06:32:34 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/tests/testNameConfigurable.py	Thu Dec 12 10:28:18 2002
@@ -29,9 +29,21 @@
     def __init__(self, **kw):
         self.__dict__.update(kw)
 
+    def getComponent(self):
+        return self.component
+
+
 class RegistryStub:
 
-    pass
+    def __init__(self, nonzero=0, active=None):
+        self._nonzero = nonzero or (active and 1 or 0)
+        self._active = active
+
+    def __nonzero__(self):
+        return self._nonzero
+
+    def active(self):
+        return self._active
 
 
 class TestNameConfigurable(TestCase):
@@ -104,6 +116,18 @@
         self.assertEquals(tuple(subject.listConfigurationNames()), ('Foo',))
         subject._bindings['Bar'] = 0   # false values should be filtered out
         self.assertEquals(tuple(subject.listConfigurationNames()), ('Foo',))
+
+    def test_queryActiveComponent(self):
+        subject = self.subject
+        self.assertEquals(subject.queryActiveComponent('xyzzy'), None)
+        self.assertEquals(subject.queryActiveComponent('xyzzy', 'No'), 'No')
+        subject._bindings['xyzzy'] = RegistryStub()
+        self.assertEquals(subject.queryActiveComponent('xyzzy'), None)
+        subject._bindings['xyzzy'] = RegistryStub(nonzero=1)
+        self.assertEquals(subject.queryActiveComponent('xyzzy'), None)
+        cfg = ConfigurationStub(component='X')
+        subject._bindings['xyzzy'] = RegistryStub(active=cfg)
+        self.assertEquals(subject.queryActiveComponent('xyzzy'), 'X')
 
 
 def test_suite():