[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ApplicationControl/ServerControl/tests - testIServerControl.py:1.1.2.2

Christian Theune ct@gocept.com
Thu, 18 Apr 2002 16:03:14 -0400


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

Modified Files:
      Tag: Zope-3x-branch
	testIServerControl.py 
Log Message:
- Removed the StubServerControl

- Added the ServerControl which implements a full server control (without the actual
    shutdown/restarting capabilities, as those are factored out to hookable methods,
    and we need to discuss how the shutdown will happen exactly - some asyncore rewriting
    is planned AFAIK)

- updated unit tests



=== Zope3/lib/python/Zope/App/OFS/ApplicationControl/ServerControl/tests/testIServerControl.py 1.1.2.1 => 1.1.2.2 ===
 
 from Zope.ComponentArchitecture import getUtility, provideUtility
-from Zope.App.OFS.ApplicationControl.ServerControl.IServerControl import IServerControl
+from Zope.App.OFS.ApplicationControl.ServerControl.IServerControl import IServerControl, DoublePriorityError, NotCallableError
 
 
 #############################################################################
@@ -33,6 +33,10 @@
 
 #############################################################################
 
+def stub_callback():
+    """stupid callable object"""
+    pass
+
 class BaseTestIServerControl:
     """Base test cases for ServerControllers.
 
@@ -46,10 +50,20 @@
     def test_IVerify(self):
         verifyObject(IServerControl, self._Test__new())
 
+    def test_registerShutdownHook(self):
+        server_control = self._Test__new()
+
+        # Try to register a noncallable object
+        self.assertRaises(NotCallableError, server_control.registerShutdownHook, None, 10, "test")
+        
+        # Try to register a priority for a second time
+        server_control.registerShutdownHook(stub_callback, 10, "Test")
+        self.assertRaises(DoublePriorityError, server_control.registerShutdownHook, stub_callback, 10, "test2")
+
 class Test(BaseTestIServerControl, TestCase):
     def _Test__new(self):
-        from Zope.App.OFS.ApplicationControl.ServerControl.StubServerControl import StubServerControl
-        return StubServerControl()
+        from Zope.App.OFS.ApplicationControl.ServerControl.ServerControl import ServerControl
+        return ServerControl()
 
 def test_suite():
     return TestSuite((