Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix structured location test

  • Loading branch information
m0rgen committed Apr 1, 2014
1 parent 76a4eba commit debc8b80af321d8bc020a1ab58ff8e872c0a72ce
@@ -287,6 +287,10 @@ def _saveRecord(self, typeName, recordType, command, oldFields=None):

fields[field] = value

if FieldName.shortNames not in fields:
# No short names were provided, so copy from uid
fields[FieldName.shortNames] = [fields[FieldName.uid]]

record = DirectoryRecord(self.dir, fields)
yield self.dir.updateRecords([record], create=create)

@@ -87,5 +87,34 @@ limitations under the License.
<password>location01</password>
<full-name>Room 01</full-name>
</record>
<record type="location">
<short-name>room-with-address-1</short-name>
<uid>room-addr-1</uid>
<guid>634A102B-6902-464F-9451-8A86A31628C1</guid>
<password>room-addr-2</password>
<full-name>Room with Address 1</full-name>
<associatedAddress>1-infinite-loop</associatedAddress>
</record>
<record type="location">
<short-name>room-with-address-2</short-name>
<uid>room-addr-2</uid>
<password>room-addr-2</password>
<full-name>Room with Address 2</full-name>
<associatedAddress>2-infinite-loop</associatedAddress>
</record>
<record type="address">
<short-name>il1</short-name>
<uid>1-infinite-loop</uid>
<full-name>One Infinite Loop</full-name>
<streetAddress>1 Infinite Loop, Cupertino, CA 95014</streetAddress>
<geographicLocation>37.331741,-122.030333</geographicLocation>
</record>
<record type="address">
<short-name>il2</short-name>
<uid>2-infinite-loop</uid>
<full-name>Two Infinite Loop</full-name>
<streetAddress>2 Infinite Loop, Cupertino, CA 95014</streetAddress>
<geographicLocation>37.332633,-122.030502</geographicLocation>
</record>

</directory>
@@ -2273,15 +2273,16 @@ def addStructuredLocation(self, component):
X-APPLE-STRUCTURED-LOCATION property and update the LOCATION property
to contain the name and street address.
"""
dir = self.directoryService()
for sub in component.subcomponents():
for attendee in sub.getAllAttendeeProperties():
if attendee.parameterValue("CUTYPE") == "ROOM":
value = attendee.value()
loc = yield self.directoryService().recordWithCalendarUserAddress(value)
loc = yield dir.recordWithCalendarUserAddress(value)
if loc is not None:
uid = getattr(loc, "associatedAddress", "")
if uid:
addr = yield self.directoryService().recordWithUID(uid)
addr = yield dir.recordWithUID(uid)
if addr is not None:
street = getattr(addr, "streetAddress", "")
geo = getattr(addr, "geographicLocation", "")
@@ -63,12 +63,20 @@ def __init__(
cutype="INDIVIDUAL",
thisServer=True,
server=None,
extras={},
associatedAddress=None,
streetAddress=None,
geographicLocation=None
):

super(TestCalendarStoreDirectoryRecord, self).__init__(uid, shortNames, fullName, thisServer, server, extras=extras)
super(TestCalendarStoreDirectoryRecord, self).__init__(
uid, shortNames, fullName, thisServer, server,
)
self.calendarUserAddresses = calendarUserAddresses
self.cutype = cutype
self.associatedAddress = associatedAddress
self.streetAddress = streetAddress
self.geographicLocation = geographicLocation



def canonicalCalendarUserAddress(self):
@@ -169,31 +177,23 @@ def buildDirectory(homes=None):
# Structured Locations
directory.addRecord(TestCalendarStoreDirectoryRecord(
"il1", ("il1",), "1 Infinite Loop", [],
extras={
"geo" : "37.331741,-122.030333",
"streetAddress" : "1 Infinite Loop, Cupertino, CA 95014",
}
geographicLocation="37.331741,-122.030333",
streetAddress="1 Infinite Loop, Cupertino, CA 95014"
))
directory.addRecord(TestCalendarStoreDirectoryRecord(
"il2", ("il2",), "2 Infinite Loop", [],
extras={
"geo" : "37.332633,-122.030502",
"streetAddress" : "2 Infinite Loop, Cupertino, CA 95014",
}
geographicLocation="37.332633,-122.030502",
streetAddress="2 Infinite Loop, Cupertino, CA 95014"
))
directory.addRecord(TestCalendarStoreDirectoryRecord(
"room1", ("room1",), "Conference Room One",
frozenset(("urn:uuid:room1",)),
extras={
"associatedAddress" : "il1",
}
associatedAddress="il1",
))
directory.addRecord(TestCalendarStoreDirectoryRecord(
"room2", ("room2",), "Conference Room Two",
frozenset(("urn:uuid:room2",)),
extras={
"associatedAddress" : "il2",
}
associatedAddress="il2",
))

return directory

0 comments on commit debc8b8

Please sign in to comment.
You can’t perform that action at this time.