[CalendarServer-changes] [14703] CalendarServer/trunk/txdav/who
source_changes at macosforge.org
source_changes at macosforge.org
Fri Apr 24 07:34:30 PDT 2015
Revision: 14703
http://trac.calendarserver.org//changeset/14703
Author: cdaboo at apple.com
Date: 2015-04-24 07:34:30 -0700 (Fri, 24 Apr 2015)
Log Message:
-----------
PyCalendar requires that property parameters are lists not tuples.
Modified Paths:
--------------
CalendarServer/trunk/txdav/who/test/test_group_attendees.py
CalendarServer/trunk/txdav/who/vcard.py
Added Paths:
-----------
CalendarServer/trunk/txdav/who/test/accounts/vcards.xml
CalendarServer/trunk/txdav/who/test/test_vcard.py
Added: CalendarServer/trunk/txdav/who/test/accounts/vcards.xml
===================================================================
--- CalendarServer/trunk/txdav/who/test/accounts/vcards.xml (rev 0)
+++ CalendarServer/trunk/txdav/who/test/accounts/vcards.xml 2015-04-24 14:34:30 UTC (rev 14703)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+Copyright (c) 2006-2015 Apple Inc. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+ -->
+
+<!DOCTYPE accounts SYSTEM "accounts.dtd">
+
+<directory realm="Test Realm">
+ <record type="user">
+ <uid>admin</uid>
+ <short-name>admin</short-name>
+ <password>admin</password>
+ <full-name>Super User</full-name>
+ </record>
+ <record type="user">
+ <uid>id1</uid>
+ <short-name>id1</short-name>
+ <password>secret</password>
+ <full-name>User 01</full-name>
+ </record>
+ <record type="user">
+ <uid>id2</uid>
+ <short-name>id2</short-name>
+ <password>secret</password>
+ <email>user02 at example.com</email>
+ <full-name>User 02</full-name>
+ </record>
+ <record type="user">
+ <uid>id3</uid>
+ <short-name>id3</short-name>
+ <password>secret</password>
+ <email>user03 at example.com</email>
+ <email>user03+plus at example.com</email>
+ <full-name>User 03</full-name>
+ </record>
+ <record type="user">
+ <uid>id4</uid>
+ <short-name>id4</short-name>
+ <password>secret</password>
+ <full-name>User 04</full-name>
+ <street-address>20300 Stevens Creek Blvd, Cupertino, CA 95014</street-address>
+ </record>
+</directory>
Modified: CalendarServer/trunk/txdav/who/test/test_group_attendees.py
===================================================================
--- CalendarServer/trunk/txdav/who/test/test_group_attendees.py 2015-04-24 02:56:27 UTC (rev 14702)
+++ CalendarServer/trunk/txdav/who/test/test_group_attendees.py 2015-04-24 14:34:30 UTC (rev 14703)
@@ -1765,7 +1765,6 @@
instances in the future.
"""
- from twistedcaldav.stdconfig import config
self.patch(config, "EnableTrashCollection", True)
data_put_1 = """BEGIN:VCALENDAR
@@ -1868,7 +1867,6 @@
in the past and future.
"""
- from twistedcaldav.stdconfig import config
self.patch(config, "EnableTrashCollection", True)
data_put_1 = """BEGIN:VCALENDAR
Added: CalendarServer/trunk/txdav/who/test/test_vcard.py
===================================================================
--- CalendarServer/trunk/txdav/who/test/test_vcard.py (rev 0)
+++ CalendarServer/trunk/txdav/who/test/test_vcard.py 2015-04-24 14:34:30 UTC (rev 14703)
@@ -0,0 +1,187 @@
+##
+# Copyright (c) 2014-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from __future__ import absolute_import
+from __future__ import print_function
+from twisted.internet.defer import inlineCallbacks
+from twisted.python.filepath import FilePath
+from twisted.trial import unittest
+from txdav.common.datastore.test.util import CommonCommonTests, \
+ populateCalendarsFrom, populateAddressBooksFrom
+from txdav.who.vcard import vCardFromRecord
+import os
+from twistedcaldav.config import config
+
+
+
+class TestVCard(CommonCommonTests, unittest.TestCase):
+ """
+ Tests for L{twext.who.vcard}.
+ """
+
+ @inlineCallbacks
+ def setUp(self):
+ yield super(TestVCard, self).setUp()
+
+ accountsFilePath = FilePath(
+ os.path.join(os.path.dirname(__file__), "accounts")
+ )
+ yield self.buildStoreAndDirectory(
+ accounts=accountsFilePath.child("vcards.xml"),
+ )
+
+ yield self.populate()
+
+
+ @inlineCallbacks
+ def populate(self):
+ yield populateCalendarsFrom(self.requirements, self.storeUnderTest())
+ yield populateAddressBooksFrom(self.requirements, self.storeUnderTest())
+
+ requirements = {
+ "id1" : None,
+ }
+
+
+ @inlineCallbacks
+ def test_basicVcard(self):
+ vcard_result = """BEGIN:VCARD
+VERSION:3.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+UID:id1
+FN:User 01
+KIND:individual
+N:01;User;;;
+END:VCARD
+""".replace("\n", "\r\n")
+
+ record = yield self.directory.recordWithUID("id1")
+ vcard = yield vCardFromRecord(record)
+ self.assertEqual(str(vcard), vcard_result)
+
+
+ @inlineCallbacks
+ def test_parentURI(self):
+ vcard_result = """BEGIN:VCARD
+VERSION:3.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+UID:id1
+FN:User 01
+KIND:individual
+N:01;User;;;
+SOURCE:https://example.com:8443/contacts/id1.vcf
+END:VCARD
+""".replace("\n", "\r\n")
+
+ self.patch(config, "EnableSSL", True)
+ self.patch(config, "SSLPort", 8443)
+ self.patch(config, "ServerHostName", "example.com")
+
+ record = yield self.directory.recordWithUID("id1")
+ vcard = yield vCardFromRecord(record, parentURI="/contacts")
+ self.assertEqual(str(vcard), vcard_result)
+
+
+ @inlineCallbacks
+ def test_forceKind(self):
+ vcard_result = """BEGIN:VCARD
+VERSION:3.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+UID:id1
+FN:User 01
+KIND:foobar
+N:01;User;;;
+END:VCARD
+""".replace("\n", "\r\n")
+
+ record = yield self.directory.recordWithUID("id1")
+ vcard = yield vCardFromRecord(record, forceKind="foobar")
+ self.assertEqual(str(vcard), vcard_result)
+
+
+ @inlineCallbacks
+ def test_addProps(self):
+ vcard_result = """BEGIN:VCARD
+VERSION:3.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+UID:id1
+FN:User 01
+KEY:private
+KIND:individual
+N:01;User;;;
+END:VCARD
+""".replace("\n", "\r\n")
+
+ record = yield self.directory.recordWithUID("id1")
+ vcard = yield vCardFromRecord(record, addProps={"KEY": "private"})
+ self.assertEqual(str(vcard), vcard_result)
+
+
+ @inlineCallbacks
+ def test_email(self):
+ vcard_result = """BEGIN:VCARD
+VERSION:3.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+UID:id2
+EMAIL;TYPE=INTERNET,PREF,WORK:user02 at example.com
+FN:User 02
+KIND:individual
+N:02;User;;;
+END:VCARD
+""".replace("\n", "\r\n")
+
+ record = yield self.directory.recordWithUID("id2")
+ vcard = yield vCardFromRecord(record)
+ self.assertEqual(str(vcard), vcard_result)
+
+
+ @inlineCallbacks
+ def test_multipleemail(self):
+ vcard_result = """BEGIN:VCARD
+VERSION:3.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+UID:id3
+EMAIL;TYPE=INTERNET,PREF,WORK:user03 at example.com
+EMAIL;TYPE=INTERNET,WORK:user03+plus at example.com
+FN:User 03
+KIND:individual
+N:03;User;;;
+END:VCARD
+""".replace("\n", "\r\n")
+
+ record = yield self.directory.recordWithUID("id3")
+ vcard = yield vCardFromRecord(record)
+ self.assertEqual(str(vcard), vcard_result)
+
+
+ @inlineCallbacks
+ def test_adr(self):
+ vcard_result = """BEGIN:VCARD
+VERSION:3.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+UID:id4
+ADR;LABEL="20300 Stevens Creek Blvd, Cupertino, CA 95014";TYPE=PARCEL,POST
+ AL,PREF,WORK:;;20300 Stevens Creek Blvd\\, Cupertino\\, CA 95014;;;;
+FN:User 04
+KIND:individual
+LABEL;TYPE=PARCEL,POSTAL:20300 Stevens Creek Blvd\\, Cupertino\\, CA 95014
+N:04;User;;;
+END:VCARD
+""".replace("\n", "\r\n")
+
+ record = yield self.directory.recordWithUID("id4")
+ vcard = yield vCardFromRecord(record)
+ self.assertEqual(str(vcard), vcard_result)
Modified: CalendarServer/trunk/txdav/who/vcard.py
===================================================================
--- CalendarServer/trunk/txdav/who/vcard.py 2015-04-24 02:56:27 UTC (rev 14702)
+++ CalendarServer/trunk/txdav/who/vcard.py 2015-04-24 14:34:30 UTC (rev 14703)
@@ -212,7 +212,7 @@
country = None
if extended or street or city or region or postalcode or country or params:
- params["TYPE"] = ("WORK", "PREF", "POSTAL", "PARCEL",)
+ params["TYPE"] = ["WORK", "PREF", "POSTAL", "PARCEL", ]
vcard.addProperty(
Property(
"ADR", Adr(
@@ -241,11 +241,11 @@
# 3.3.1 TEL
# 3.3.2 EMAIL
- preferredWorkParams = {"TYPE": ("WORK", "PREF", "INTERNET",), }
- workParams = {"TYPE": ("WORK", "INTERNET",), }
+ preferredWorkParams = {"TYPE": ["WORK", "PREF", "INTERNET", ], }
+ workParams = {"TYPE": ["WORK", "INTERNET", ], }
params = preferredWorkParams
for emailAddress in record.fields.get(FieldName.emailAddresses, ()):
- addUniqueProperty(Property("EMAIL", emailAddress.encode("utf-8"), params=params), ignoredParameters={"TYPE": ("PREF",)})
+ addUniqueProperty(Property("EMAIL", emailAddress.encode("utf-8"), params=params), ignoredParameters={"TYPE": ["PREF", ]})
params = workParams
# UNIMPLEMENTED:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150424/004aad18/attachment-0001.html>
More information about the calendarserver-changes
mailing list