<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14703] CalendarServer/trunk/txdav/who</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14703">14703</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2015-04-24 07:34:30 -0700 (Fri, 24 Apr 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>PyCalendar requires that property parameters are lists not tuples.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktxdavwhotesttest_group_attendeespy">CalendarServer/trunk/txdav/who/test/test_group_attendees.py</a></li>
<li><a href="#CalendarServertrunktxdavwhovcardpy">CalendarServer/trunk/txdav/who/vcard.py</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServertrunktxdavwhotestaccountsvcardsxml">CalendarServer/trunk/txdav/who/test/accounts/vcards.xml</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_vcardpy">CalendarServer/trunk/txdav/who/test/test_vcard.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktxdavwhotestaccountsvcardsxml"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/txdav/who/test/accounts/vcards.xml (0 => 14703)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+<?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@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@example.com</email>
+ <email>user03+plus@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>
</ins></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_group_attendeespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_group_attendees.py (14702 => 14703)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1765,7 +1765,6 @@
</span><span class="cx"> instances in the future.
</span><span class="cx"> """
</span><span class="cx">
</span><del>- from twistedcaldav.stdconfig import config
</del><span class="cx"> self.patch(config, "EnableTrashCollection", True)
</span><span class="cx">
</span><span class="cx"> data_put_1 = """BEGIN:VCALENDAR
</span><span class="lines">@@ -1868,7 +1867,6 @@
</span><span class="cx"> in the past and future.
</span><span class="cx"> """
</span><span class="cx">
</span><del>- from twistedcaldav.stdconfig import config
</del><span class="cx"> self.patch(config, "EnableTrashCollection", True)
</span><span class="cx">
</span><span class="cx"> data_put_1 = """BEGIN:VCALENDAR
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_vcardpy"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/txdav/who/test/test_vcard.py (0 => 14703)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,187 @@
</span><ins>+##
+# 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@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@example.com
+EMAIL;TYPE=INTERNET,WORK:user03+plus@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)
</ins></span></pre></div>
<a id="CalendarServertrunktxdavwhovcardpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/vcard.py (14702 => 14703)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -212,7 +212,7 @@
</span><span class="cx"> country = None
</span><span class="cx">
</span><span class="cx"> if extended or street or city or region or postalcode or country or params:
</span><del>- params["TYPE"] = ("WORK", "PREF", "POSTAL", "PARCEL",)
</del><ins>+ params["TYPE"] = ["WORK", "PREF", "POSTAL", "PARCEL", ]
</ins><span class="cx"> vcard.addProperty(
</span><span class="cx"> Property(
</span><span class="cx"> "ADR", Adr(
</span><span class="lines">@@ -241,11 +241,11 @@
</span><span class="cx"> # 3.3.1 TEL
</span><span class="cx">
</span><span class="cx"> # 3.3.2 EMAIL
</span><del>- preferredWorkParams = {"TYPE": ("WORK", "PREF", "INTERNET",), }
- workParams = {"TYPE": ("WORK", "INTERNET",), }
</del><ins>+ preferredWorkParams = {"TYPE": ["WORK", "PREF", "INTERNET", ], }
+ workParams = {"TYPE": ["WORK", "INTERNET", ], }
</ins><span class="cx"> params = preferredWorkParams
</span><span class="cx"> for emailAddress in record.fields.get(FieldName.emailAddresses, ()):
</span><del>- addUniqueProperty(Property("EMAIL", emailAddress.encode("utf-8"), params=params), ignoredParameters={"TYPE": ("PREF",)})
</del><ins>+ addUniqueProperty(Property("EMAIL", emailAddress.encode("utf-8"), params=params), ignoredParameters={"TYPE": ["PREF", ]})
</ins><span class="cx"> params = workParams
</span><span class="cx">
</span><span class="cx"> # UNIMPLEMENTED:
</span></span></pre>
</div>
</div>
</body>
</html>