[CalendarServer-changes] [11434] CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/ python
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jun 26 01:22:14 PDT 2013
Revision: 11434
http://trac.calendarserver.org//changeset/11434
Author: glyph at apple.com
Date: 2013-06-26 01:22:14 -0700 (Wed, 26 Jun 2013)
Log Message:
-----------
Implement & test the function that was the point of all this...
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:21:58 UTC (rev 11433)
+++ CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/launchd.py 2013-06-26 08:22:14 UTC (rev 11434)
@@ -278,15 +278,14 @@
def getLaunchDSocketFDs():
- result = {}
- response = {}
- label = response[lib.LAUNCH_JOBKEY_LABEL]
- skts = response[lib.LAUNCH_JOBKEY_SOCKETS]
- result['label'] = label
- result['sockets'] = list(skts['TestSocket'])
- return result
+ """
+ Perform checkin via L{checkin} and return just a dictionary mapping the
+ sockets to file descriptors.
+ """
+ return plainPython(checkin()[constants.LAUNCH_JOBKEY_SOCKETS])
+
__all__ = [
'checkin',
'lib',
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:21:58 UTC (rev 11433)
+++ CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py 2013-06-26 08:22:14 UTC (rev 11434)
@@ -38,9 +38,10 @@
try:
- from twext.python.launchd import (lib, ffi, _LaunchDictionary, _LaunchArray,
- _managed, constants, plainPython, checkin,
- _launchify)
+ from twext.python.launchd import (
+ lib, ffi, _LaunchDictionary, _LaunchArray, _managed, constants,
+ plainPython, checkin, _launchify, getLaunchDSocketFDs
+ )
except ImportError:
skip = "LaunchD not available."
else:
@@ -107,7 +108,7 @@
self.assertEquals(lib.launch_data_dict_get_count(self.testDict), 3)
- def test__LaunchDictionaryLength(self):
+ def test_len(self):
"""
C{len(_LaunchDictionary())} returns the number of keys in the
dictionary.
@@ -115,7 +116,7 @@
self.assertEquals(len(_LaunchDictionary(self.testDict)), 3)
- def test__LaunchDictionaryKeys(self):
+ def test_keys(self):
"""
L{_LaunchDictionary.keys} returns keys present in a C{launch_data_dict}.
"""
@@ -124,7 +125,7 @@
set([b"alpha", b"beta", b"gamma"]))
- def test__LaunchDictionaryValues(self):
+ def test_values(self):
"""
L{_LaunchDictionary.values} returns keys present in a
C{launch_data_dict}.
@@ -134,7 +135,7 @@
set([b"alpha-value", b"beta-value", 3]))
- def test__LaunchDictionaryItems(self):
+ def test_items(self):
"""
L{_LaunchDictionary.items} returns all (key, value) tuples present in a
C{launch_data_dict}.
@@ -145,7 +146,7 @@
(b"beta", b"beta-value"), (b"gamma", 3)]))
- def test__LaunchDictionaryPlainPython(self):
+ def test_plainPython(self):
"""
L{plainPython} will convert a L{_LaunchDictionary} into a Python
dictionary.
@@ -155,7 +156,7 @@
plainPython(_LaunchDictionary(self.testDict)))
- def test_nested_LaunchDictionaryPlainPython(self):
+ def test_plainPythonNested(self):
"""
L{plainPython} will convert a L{_LaunchDictionary} containing another
L{_LaunchDictionary} into a nested Python dictionary.
@@ -360,6 +361,29 @@
self.assertIsInstance(awesomeSocket[0], int)
+ @staticmethod
+ def job_getFDs():
+ """
+ Check-in via the high-level C{getLaunchDSocketFDs} API, that just gives
+ us listening FDs.
+ """
+ sys.stdout.write(json.dumps(getLaunchDSocketFDs()))
+
+
+ def test_getFDs(self):
+ """
+ L{getLaunchDSocketFDs} returns a Python dictionary mapping the names of
+ sockets specified in the property list to lists of integers
+ representing FDs.
+ """
+ sockets = json.loads(self.stdout.getContent())
+ self.assertEquals(len(sockets), 1)
+ self.assertEqual(['Awesome'], sockets.keys())
+ awesomeSocket = sockets['Awesome']
+ self.assertEqual(len(awesomeSocket), 1)
+ self.assertIsInstance(awesomeSocket[0], int)
+
+
def tearDown(self):
"""
Un-load the launchd job and report any errors it encountered.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130626/0ccc397e/attachment-0001.html>
More information about the calendarserver-changes
mailing list