[CalendarServer-changes] [6523] CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/ test/test_caldav.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Nov 1 14:22:11 PDT 2010
Revision: 6523
http://trac.macosforge.org/projects/calendarserver/changeset/6523
Author: glyph at apple.com
Date: 2010-11-01 14:22:08 -0700 (Mon, 01 Nov 2010)
Log Message:
-----------
Test case for changing arguments on the fly. (Also indirectly tests respawning.)
Modified Paths:
--------------
CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/test/test_caldav.py
Modified: CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/test/test_caldav.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/test/test_caldav.py 2010-11-01 21:21:47 UTC (rev 6522)
+++ CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/test/test_caldav.py 2010-11-01 21:22:08 UTC (rev 6523)
@@ -894,22 +894,22 @@
class DummyProcessObject(object):
"""
- Simple stub for the Process Object API that will run a test script.
+ Simple stub for Process Object API which just has an executable and some
+ arguments.
This is a stand in for L{TwistdSlaveProcess}.
"""
def __init__(self, scriptname, *args):
self.scriptname = scriptname
- self.args = list(args)
+ self.args = args
def getCommandLine(self):
"""
- Get the command line to invoke this script.
+ Simple command line.
"""
- return [sys.executable,
- FilePath(__file__).sibling(self.scriptname).path] + self.args
+ return [self.scriptname] + list(self.args)
def getFileDescriptors(self):
@@ -926,7 +926,24 @@
return 'Dummy'
+class ScriptProcessObject(DummyProcessObject):
+ """
+ Simple stub for the Process Object API that will run a test script.
+ """
+ def getCommandLine(self):
+ """
+ Get the command line to invoke this script.
+ """
+ return [
+ sys.executable,
+ FilePath(__file__).sibling(self.scriptname).path
+ ] + list(self.args)
+
+
+
+
+
class DelayedStartupProcessMonitorTests(TestCase):
"""
Test cases for L{DelayedStartupProcessMonitor}.
@@ -939,7 +956,7 @@
at once, to avoid resource exhaustion.
"""
dspm = DelayedStartupProcessMonitor()
- dspm.addProcessObject(DummyProcessObject(
+ dspm.addProcessObject(ScriptProcessObject(
'longlines.py', str(DelayedStartupLineLogger.MAX_LENGTH)),
os.environ)
dspm.startService()
@@ -1011,6 +1028,27 @@
19: 19, 25: 25})
+ def test_changedArgumentEachSpawn(self):
+ """
+ If the result of C{getCommandLine} changes on subsequent calls,
+ subsequent calls should result in different arguments being passed to
+ C{spawnProcess} each time.
+ """
+ imps = InMemoryProcessSpawner()
+ dspm = DelayedStartupProcessMonitor(imps)
+ slave = DummyProcessObject('scriptname', 'first')
+ dspm.addProcessObject(slave, {})
+ dspm.startService()
+ oneProcessTransport = imps.waitForOneProcess()
+ self.assertEquals(oneProcessTransport.args,
+ ['scriptname', 'first'])
+ slave.args = ['second']
+ oneProcessTransport.processProtocol.processEnded(None)
+ twoProcessTransport = imps.waitForOneProcess()
+ self.assertEquals(twoProcessTransport.args,
+ ['scriptname', 'second'])
+
+
def test_metaDescriptorInheritance(self):
"""
If a L{TwistdSlaveProcess} specifies a meta-file-descriptor to be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101101/5c14b35b/attachment.html>
More information about the calendarserver-changes
mailing list