[CalendarServer-changes] [13060] CalendarServer/branches/users/sagen/move2who-4
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 31 13:17:32 PDT 2014
Revision: 13060
http://trac.calendarserver.org//changeset/13060
Author: sagen at apple.com
Date: 2014-03-31 13:17:32 -0700 (Mon, 31 Mar 2014)
Log Message:
-----------
More tests for locations and addresses
Modified Paths:
--------------
CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/test/test_gateway.py
CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/sql.py
Modified: CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/test/test_gateway.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/test/test_gateway.py 2014-03-31 20:16:25 UTC (rev 13059)
+++ CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/test/test_gateway.py 2014-03-31 20:17:32 UTC (rev 13060)
@@ -321,7 +321,6 @@
# self.assertEquals(record.extras["comment"], "Updated Test Comment")
self.assertEquals(record.floor, "Second")
# self.assertEquals(record.extras["capacity"], "41")
- self.assertEquals(record.streetAddress, "2 Infinite Loop\nCupertino, 95014\nCA")
self.assertEquals(record.autoScheduleMode, AutoScheduleMode.acceptIfFree)
self.assertEquals(record.autoAcceptGroup, "F5A6142C-4189-4E9E-90B0-9CD0268B314B")
@@ -333,6 +332,24 @@
@inlineCallbacks
+ def test_setAddressOnLocation(self):
+ yield self.runCommand(command_createLocation)
+ yield self.runCommand(command_createAddress)
+ yield self.runCommand(command_setAddressOnLocation)
+ results = yield self.runCommand(command_getLocationAttributes)
+ self.assertEquals(results["result"]["AssociatedAddress"], "C701069D-9CA1-4925-A1A9-5CD94767B74B")
+ self._flush()
+ record = yield self.directory.recordWithUID("836B1B66-2E9A-4F46-8B1C-3DD6772C20B2")
+ self.assertEquals(record.associatedAddress, "C701069D-9CA1-4925-A1A9-5CD94767B74B")
+ yield self.runCommand(command_removeAddressFromLocation)
+ results = yield self.runCommand(command_getLocationAttributes)
+ self.assertEquals(results["result"]["AssociatedAddress"], "")
+ self._flush()
+ record = yield self.directory.recordWithUID("836B1B66-2E9A-4F46-8B1C-3DD6772C20B2")
+ self.assertEquals(record.associatedAddress, u"")
+
+
+ @inlineCallbacks
def test_destroyLocation(self):
record = yield self.directory.recordWithUID("location01")
@@ -755,8 +772,6 @@
<key>Capacity</key>
<string>41</string>
-->
- <key>StreetAddress</key>
- <string>2 Infinite Loop\nCupertino, 95014\nCA</string>
<key>ReadProxies</key>
<array>
<string>user03</string>
@@ -771,6 +786,35 @@
</plist>
"""
+command_setAddressOnLocation = """<?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>setLocationAttributes</string>
+ <key>GeneratedUID</key>
+ <string>836B1B66-2E9A-4F46-8B1C-3DD6772C20B2</string>
+ <key>AssociatedAddress</key>
+ <string>C701069D-9CA1-4925-A1A9-5CD94767B74B</string>
+</dict>
+</plist>
+"""
+
+command_removeAddressFromLocation = """<?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>setLocationAttributes</string>
+ <key>GeneratedUID</key>
+ <string>836B1B66-2E9A-4F46-8B1C-3DD6772C20B2</string>
+ <key>AssociatedAddress</key>
+ <string></string>
+</dict>
+</plist>
+"""
+
+
command_getLocationAttributes = """<?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">
Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/sql.py 2014-03-31 20:16:25 UTC (rev 13059)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/sql.py 2014-03-31 20:17:32 UTC (rev 13060)
@@ -2277,23 +2277,23 @@
for attendee in sub.getAllAttendeeProperties():
if attendee.parameterValue("CUTYPE") == "ROOM":
value = attendee.value()
+ # FIXME: this should use recordWithCalendarUserAddress(), right?
if value.startswith("urn:uuid:"):
guid = value[9:]
loc = yield self.directoryService().recordWithGUID(guid)
if loc is not None:
- guid = loc.extras.get("associatedAddress",
- None)
- if guid is not None:
- addr = yield self.directoryService().recordWithGUID(guid)
+ uid = getattr(loc, "associatedAddress", "")
+ if uid:
+ addr = yield self.directoryService().recordWithUID(uid)
if addr is not None:
- street = addr.extras.get("streetAddress", "")
- geo = addr.extras.get("geo", "")
+ street = getattr(addr, "streetAddress", "")
+ geo = getattr(addr, "geographicLocation", "")
if street and geo:
title = attendee.parameterValue("CN")
params = {
- "X-ADDRESS" : street,
- "X-APPLE-RADIUS" : "71",
- "X-TITLE" : title,
+ "X-ADDRESS": street,
+ "X-APPLE-RADIUS": "71",
+ "X-TITLE": title,
}
structured = Property("X-APPLE-STRUCTURED-LOCATION",
"geo:%s" % (geo,), params=params,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140331/1757b03b/attachment.html>
More information about the calendarserver-changes
mailing list