[Zope3-checkins]
CVS: Zope3/src/zope/app/applicationcontrol/browser/tests
- test_servercontrolview.py:1.4
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Mar 23 10:52:13 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/applicationcontrol/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv2015/src/zope/app/applicationcontrol/browser/tests
Modified Files:
test_servercontrolview.py
Log Message:
Ripped out old shutdown hook code. Replaced code by better utility-based
model.
There are some to-do's missing, such as creating events, allowing graceful
shutdown and restart and so on. It's in TODOLATER.txt.
=== Zope3/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py:1.3 Sat Mar 13 18:54:57 2004
+++ Zope3/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py Tue Mar 23 10:52:12 2004
@@ -17,14 +17,27 @@
"""
import unittest
+from zope.interface import implements
+from zope.app import zapi
from zope.app.applicationcontrol.applicationcontrol import applicationController
-from zope.app.applicationcontrol.servercontrol import ServerControl
from zope.app.applicationcontrol.browser.servercontrol import ServerControlView
from zope.app.applicationcontrol.interfaces import IServerControl
from zope.app.servicenames import Utilities
from zope.app.site.tests.placefulsetup import PlacefulSetup
from zope.component import getService
+class ServerControlStub(object):
+ implements(IServerControl)
+
+ did_restart = None
+ did_shutdown = None
+
+ def restart(self, time):
+ self.did_restart = time
+
+ def shutdown(self, time):
+ self.did_shutdown = time
+
class Test(PlacefulSetup, unittest.TestCase):
def _TestView__newView(self, container, request):
@@ -34,20 +47,22 @@
return view
def test_ServerControlView(self):
- getService(None,Utilities).provideUtility(
- IServerControl, ServerControl())
+ control = ServerControlStub()
+ zapi.getService(None, Utilities).provideUtility(IServerControl, control)
test_serverctrl = self._TestView__newView(
applicationController,
{'shutdown': 1},
)
- test_serverctrl.action()
+ test_serverctrl.action(100)
+ self.assertEqual(control.did_shutdown, 100)
test_serverctrl = self._TestView__newView(
applicationController,
{'restart': 1},
)
- test_serverctrl.action()
+ test_serverctrl.action(100)
+ self.assertEqual(control.did_restart, 100)
def test_suite():
More information about the Zope3-Checkins
mailing list