[CalendarServer-changes] [11422] CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/ python
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jun 26 01:16:54 PDT 2013
Revision: 11422
http://trac.calendarserver.org//changeset/11422
Author: glyph at apple.com
Date: 2013-06-26 01:16:54 -0700 (Wed, 26 Jun 2013)
Log Message:
-----------
Start writing test for checkin, need to convert launchd structures to python structures to get them between the processes again...
Modified Paths:
--------------
CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/launchd.py
CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py
Modified: CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/launchd.py
===================================================================
--- CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/launchd.py 2013-06-26 08:16:30 UTC (rev 11421)
+++ CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/launchd.py 2013-06-26 08:16:54 UTC (rev 11422)
@@ -151,6 +151,21 @@
+def plainPython(x):
+ """
+ Convert a launchd python-like data structure into regular Python
+ dictionaries and lists.
+ """
+ if isinstance(x, LaunchDictionary):
+ result = {}
+ result.update(x)
+ return result
+ elif isinstance(x, LaunchArray):
+ result = []
+
+
+
+
class LaunchErrno(Exception):
"""
Error from launchd.
Modified: CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py
===================================================================
--- CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py 2013-06-26 08:16:30 UTC (rev 11421)
+++ CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py 2013-06-26 08:16:54 UTC (rev 11422)
@@ -24,14 +24,16 @@
testID = sys.argv[1]
a, b = testID.rsplit(".", 1)
from twisted.python.reflect import namedAny
- namedAny(".".join([a, b.replace("test_", "job_")]))()
- skt = socket.socket()
- skt.connect(("127.0.0.1", int(os.environ["TESTING_PORT"])))
+ try:
+ namedAny(".".join([a, b.replace("test_", "job_")]))()
+ finally:
+ skt = socket.socket()
+ skt.connect(("127.0.0.1", int(os.environ["TESTING_PORT"])))
sys.exit(0)
from twext.python.launchd import (lib, ffi, LaunchDictionary, LaunchArray,
- _managed, constants)
+ _managed, constants, plainPython)
from twisted.trial.unittest import TestCase
from twisted.python.filepath import FilePath
@@ -98,6 +100,16 @@
(b"beta", b"beta-value"), (b"gamma", 3)]))
+ def test_launchDictionaryPlainPython(self):
+ """
+ L{plainPython} will convert a L{LaunchDictionary} into a Python
+ dictionary.
+ """
+ self.assertEquals({b"alpha": b"alpha-value", b"beta": b"beta-value",
+ b"gamma": 3},
+ plainPython(LaunchDictionary(self.testDict)))
+
+
class ArrayTests(TestCase):
"""
Tests for L{LaunchArray}
@@ -220,8 +232,8 @@
return d
- @classmethod
- def job_test(self):
+ @staticmethod
+ def job_test():
"""
Do something observable in a subprocess.
"""
@@ -237,7 +249,20 @@
self.assertEquals("Sample Value.", self.stdout.getContent())
+ @staticmethod
+ def job_checkin():
+ """
+ Check in in the subprocess.
+ """
+ checkin()
+
+ def test_checkin(self):
+ """
+ Checking in results
+ """
+
+
def tearDown(self):
os.spawnlp(os.P_WAIT, "launchctl", "launchctl", "unload", self.job.path)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130626/02684903/attachment-0001.html>
More information about the calendarserver-changes
mailing list