[Zope-CVS] CVS: Products/Scheduler/tests - testScheduler.py:1.3
Chris McDonough
chrism@zope.com
Tue, 3 Jun 2003 10:50:46 -0400
Update of /cvs-repository/Products/Scheduler/tests
In directory cvs.zope.org:/tmp/cvs-serv1031/tests
Modified Files:
testScheduler.py
Log Message:
Allow conflict errors to permeate up to ZPublisher.
=== Products/Scheduler/tests/testScheduler.py 1.2 => 1.3 ===
--- Products/Scheduler/tests/testScheduler.py:1.2 Mon Jun 2 16:38:40 2003
+++ Products/Scheduler/tests/testScheduler.py Tue Jun 3 10:50:45 2003
@@ -6,6 +6,7 @@
from ZPublisher.HTTPResponse import HTTPResponse
from Products.PythonScripts.PythonScript import PythonScript
from Acquisition import aq_base
+from ZODB.POSException import ConflictError
from Products.Scheduler.Scheduler import Scheduler
from Products.Scheduler.Task import Task
@@ -17,10 +18,18 @@
stuff = {} # used for reporting during tests
-put_stuff = """from Products.Scheduler.tests.testScheduler import stuff
-stuff.update({'stuff_put':1})"""
-get_stuff = """from Products.Scheduler.tests.testScheduler import stuff
-return stuff"""
+put_stuff = """
+from Products.Scheduler.tests.testScheduler import stuff
+stuff.update({'stuff_put':1})
+"""
+get_stuff = """
+from Products.Scheduler.tests.testScheduler import stuff
+return stuff
+"""
+raise_conflict ="""
+from Products.Scheduler.tests.testScheduler import ConflictError
+raise ConflictError
+"""
class TestScheduler(TestCase):
def setUp(self):
@@ -33,6 +42,8 @@
app.put_stuff.ZPythonScript_edit('', put_stuff)
app._setObject('get_stuff', PythonScript('get_stuff'))
app.get_stuff.ZPythonScript_edit('', get_stuff)
+ app._setObject('raise_conflict', PythonScript('raise_conflict'))
+ app.raise_conflict.ZPythonScript_edit('', raise_conflict)
resp = HTTPResponse()
os.environ['SERVER_NAME']='server'
os.environ['SERVER_PORT']='80'
@@ -97,11 +108,22 @@
app.portal_scheduler.deschedule(tid)
assert app.portal_scheduler.checkConsistency() == 'OK'
+ def _notify(self):
+ self.app.portal_scheduler.notify()
+
+ def testConflictErrorPermeates(self):
+ app = self.app
+ now = time.time()
+ task = Task('raise_conflict', now, '/raise_conflict')
+ app.portal_scheduler.schedule(now, task)
+ self.assertRaises(ConflictError, self._notify)
+
from AccessControl import ModuleSecurityInfo
ModuleSecurityInfo('Products').declarePublic('Scheduler')
ModuleSecurityInfo('Products.Scheduler').declarePublic('tests')
ModuleSecurityInfo('Products.Scheduler.tests').declarePublic('testScheduler')
ModuleSecurityInfo('Products.Scheduler.tests.testScheduler').declarePublic('stuff')
+ModuleSecurityInfo('Products.Scheduler.tests.testScheduler').declarePublic('ConflictError')
ModuleSecurityInfo('Products.Groups.Group').declarePublic('stripGroupTag')