[CalendarServer-changes] [11145] CalendarServer/trunk/calendarserver/tools
source_changes at macosforge.org
source_changes at macosforge.org
Tue May 7 11:28:24 PDT 2013
Revision: 11145
http://trac.calendarserver.org//changeset/11145
Author: sagen at apple.com
Date: 2013-05-07 11:28:24 -0700 (Tue, 07 May 2013)
Log Message:
-----------
Adds 'getLocationAndResourceList' command which returns both locations and resources
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/gateway.py
CalendarServer/trunk/calendarserver/tools/test/test_gateway.py
Modified: CalendarServer/trunk/calendarserver/tools/gateway.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/gateway.py 2013-05-06 23:18:24 UTC (rev 11144)
+++ CalendarServer/trunk/calendarserver/tools/gateway.py 2013-05-07 18:28:24 UTC (rev 11145)
@@ -199,7 +199,7 @@
def command_getLocationList(self, command):
- respondWithRecordsOfType(self.dir, command, "locations")
+ respondWithRecordsOfTypes(self.dir, command, ["locations"])
@inlineCallbacks
@@ -220,7 +220,7 @@
principal = principalForPrincipalID(record.guid, directory=self.dir)
(yield setProxies(self.store, principal, readProxies, writeProxies, directory=self.dir))
- respondWithRecordsOfType(self.dir, command, "locations")
+ respondWithRecordsOfTypes(self.dir, command, ["locations"])
@inlineCallbacks
@@ -281,13 +281,13 @@
except DirectoryError, e:
respondWithError(str(e))
return
- respondWithRecordsOfType(self.dir, command, "locations")
+ respondWithRecordsOfTypes(self.dir, command, ["locations"])
# Resources
def command_getResourceList(self, command):
- respondWithRecordsOfType(self.dir, command, "resources")
+ respondWithRecordsOfTypes(self.dir, command, ["resources"])
@inlineCallbacks
@@ -308,7 +308,7 @@
principal = principalForPrincipalID(record.guid, directory=self.dir)
(yield setProxies(self.store, principal, readProxies, writeProxies, directory=self.dir))
- respondWithRecordsOfType(self.dir, command, "resources")
+ respondWithRecordsOfTypes(self.dir, command, ["resources"])
@inlineCallbacks
@@ -349,8 +349,13 @@
except DirectoryError, e:
respondWithError(str(e))
return
- respondWithRecordsOfType(self.dir, command, "resources")
+ respondWithRecordsOfTypes(self.dir, command, ["resources"])
+
+ def command_getLocationAndResourceList(self, command):
+ respondWithRecordsOfTypes(self.dir, command, ["locations", "resources"])
+
+
# Proxies
@@ -506,11 +511,12 @@
-def respondWithRecordsOfType(directory, command, recordType):
+def respondWithRecordsOfTypes(directory, command, recordTypes):
result = []
- for record in directory.listRecords(recordType):
- recordDict = recordToDict(record)
- result.append(recordDict)
+ for recordType in recordTypes:
+ for record in directory.listRecords(recordType):
+ recordDict = recordToDict(record)
+ result.append(recordDict)
respond(command, result)
Modified: CalendarServer/trunk/calendarserver/tools/test/test_gateway.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_gateway.py 2013-05-06 23:18:24 UTC (rev 11144)
+++ CalendarServer/trunk/calendarserver/tools/test/test_gateway.py 2013-05-07 18:28:24 UTC (rev 11145)
@@ -113,6 +113,12 @@
class GatewayTestCase(RunCommandTestCase):
@inlineCallbacks
+ def test_getLocationAndResourceList(self):
+ results = yield self.runCommand(command_getLocationAndResourceList)
+ self.assertEquals(len(results["result"]), 20)
+
+
+ @inlineCallbacks
def test_getLocationList(self):
results = yield self.runCommand(command_getLocationList)
self.assertEquals(len(results["result"]), 10)
@@ -451,6 +457,16 @@
</plist>
"""
+command_getLocationAndResourceList = """<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>command</key>
+ <string>getLocationAndResourceList</string>
+</dict>
+</plist>
+"""
+
command_getLocationList = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130507/e0751c4e/attachment.html>
More information about the calendarserver-changes
mailing list