<!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>+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+
+&lt;!--
+Copyright (c) 2006-2015 Apple Inc. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+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 &quot;AS IS&quot; 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.
+ --&gt;
+
+&lt;!DOCTYPE accounts SYSTEM &quot;accounts.dtd&quot;&gt;
+
+&lt;directory realm=&quot;Test Realm&quot;&gt;
+  &lt;record type=&quot;user&quot;&gt;
+    &lt;uid&gt;admin&lt;/uid&gt;
+    &lt;short-name&gt;admin&lt;/short-name&gt;
+    &lt;password&gt;admin&lt;/password&gt;
+    &lt;full-name&gt;Super User&lt;/full-name&gt;
+  &lt;/record&gt;
+  &lt;record type=&quot;user&quot;&gt;
+    &lt;uid&gt;id1&lt;/uid&gt;
+    &lt;short-name&gt;id1&lt;/short-name&gt;
+    &lt;password&gt;secret&lt;/password&gt;
+    &lt;full-name&gt;User 01&lt;/full-name&gt;
+  &lt;/record&gt;
+  &lt;record type=&quot;user&quot;&gt;
+    &lt;uid&gt;id2&lt;/uid&gt;
+    &lt;short-name&gt;id2&lt;/short-name&gt;
+    &lt;password&gt;secret&lt;/password&gt;
+    &lt;email&gt;user02@example.com&lt;/email&gt;
+    &lt;full-name&gt;User 02&lt;/full-name&gt;
+  &lt;/record&gt;
+  &lt;record type=&quot;user&quot;&gt;
+    &lt;uid&gt;id3&lt;/uid&gt;
+    &lt;short-name&gt;id3&lt;/short-name&gt;
+    &lt;password&gt;secret&lt;/password&gt;
+    &lt;email&gt;user03@example.com&lt;/email&gt;
+    &lt;email&gt;user03+plus@example.com&lt;/email&gt;
+    &lt;full-name&gt;User 03&lt;/full-name&gt;
+  &lt;/record&gt;
+  &lt;record type=&quot;user&quot;&gt;
+    &lt;uid&gt;id4&lt;/uid&gt;
+    &lt;short-name&gt;id4&lt;/short-name&gt;
+    &lt;password&gt;secret&lt;/password&gt;
+    &lt;full-name&gt;User 04&lt;/full-name&gt;
+        &lt;street-address&gt;20300 Stevens Creek Blvd, Cupertino, CA 95014&lt;/street-address&gt;
+  &lt;/record&gt;
+&lt;/directory&gt;
</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">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        from twistedcaldav.stdconfig import config
</del><span class="cx">         self.patch(config, &quot;EnableTrashCollection&quot;, True)
</span><span class="cx"> 
</span><span class="cx">         data_put_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
</span><span class="lines">@@ -1868,7 +1867,6 @@
</span><span class="cx">         in the past and future.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        from twistedcaldav.stdconfig import config
</del><span class="cx">         self.patch(config, &quot;EnableTrashCollection&quot;, True)
</span><span class="cx"> 
</span><span class="cx">         data_put_1 = &quot;&quot;&quot;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 &quot;License&quot;);
+# 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 &quot;AS IS&quot; 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):
+    &quot;&quot;&quot;
+    Tests for L{twext.who.vcard}.
+    &quot;&quot;&quot;
+
+    @inlineCallbacks
+    def setUp(self):
+        yield super(TestVCard, self).setUp()
+
+        accountsFilePath = FilePath(
+            os.path.join(os.path.dirname(__file__), &quot;accounts&quot;)
+        )
+        yield self.buildStoreAndDirectory(
+            accounts=accountsFilePath.child(&quot;vcards.xml&quot;),
+        )
+
+        yield self.populate()
+
+
+    @inlineCallbacks
+    def populate(self):
+        yield populateCalendarsFrom(self.requirements, self.storeUnderTest())
+        yield populateAddressBooksFrom(self.requirements, self.storeUnderTest())
+
+    requirements = {
+        &quot;id1&quot; : None,
+    }
+
+
+    @inlineCallbacks
+    def test_basicVcard(self):
+        vcard_result = &quot;&quot;&quot;BEGIN:VCARD
+VERSION:3.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+UID:id1
+FN:User 01
+KIND:individual
+N:01;User;;;
+END:VCARD
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+
+        record = yield self.directory.recordWithUID(&quot;id1&quot;)
+        vcard = yield vCardFromRecord(record)
+        self.assertEqual(str(vcard), vcard_result)
+
+
+    @inlineCallbacks
+    def test_parentURI(self):
+        vcard_result = &quot;&quot;&quot;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
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+
+        self.patch(config, &quot;EnableSSL&quot;, True)
+        self.patch(config, &quot;SSLPort&quot;, 8443)
+        self.patch(config, &quot;ServerHostName&quot;, &quot;example.com&quot;)
+
+        record = yield self.directory.recordWithUID(&quot;id1&quot;)
+        vcard = yield vCardFromRecord(record, parentURI=&quot;/contacts&quot;)
+        self.assertEqual(str(vcard), vcard_result)
+
+
+    @inlineCallbacks
+    def test_forceKind(self):
+        vcard_result = &quot;&quot;&quot;BEGIN:VCARD
+VERSION:3.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+UID:id1
+FN:User 01
+KIND:foobar
+N:01;User;;;
+END:VCARD
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+
+        record = yield self.directory.recordWithUID(&quot;id1&quot;)
+        vcard = yield vCardFromRecord(record, forceKind=&quot;foobar&quot;)
+        self.assertEqual(str(vcard), vcard_result)
+
+
+    @inlineCallbacks
+    def test_addProps(self):
+        vcard_result = &quot;&quot;&quot;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
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+
+        record = yield self.directory.recordWithUID(&quot;id1&quot;)
+        vcard = yield vCardFromRecord(record, addProps={&quot;KEY&quot;: &quot;private&quot;})
+        self.assertEqual(str(vcard), vcard_result)
+
+
+    @inlineCallbacks
+    def test_email(self):
+        vcard_result = &quot;&quot;&quot;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
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+
+        record = yield self.directory.recordWithUID(&quot;id2&quot;)
+        vcard = yield vCardFromRecord(record)
+        self.assertEqual(str(vcard), vcard_result)
+
+
+    @inlineCallbacks
+    def test_multipleemail(self):
+        vcard_result = &quot;&quot;&quot;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
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+
+        record = yield self.directory.recordWithUID(&quot;id3&quot;)
+        vcard = yield vCardFromRecord(record)
+        self.assertEqual(str(vcard), vcard_result)
+
+
+    @inlineCallbacks
+    def test_adr(self):
+        vcard_result = &quot;&quot;&quot;BEGIN:VCARD
+VERSION:3.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+UID:id4
+ADR;LABEL=&quot;20300 Stevens Creek Blvd, Cupertino, CA 95014&quot;;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
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+
+        record = yield self.directory.recordWithUID(&quot;id4&quot;)
+        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[&quot;TYPE&quot;] = (&quot;WORK&quot;, &quot;PREF&quot;, &quot;POSTAL&quot;, &quot;PARCEL&quot;,)
</del><ins>+        params[&quot;TYPE&quot;] = [&quot;WORK&quot;, &quot;PREF&quot;, &quot;POSTAL&quot;, &quot;PARCEL&quot;, ]
</ins><span class="cx">         vcard.addProperty(
</span><span class="cx">             Property(
</span><span class="cx">                 &quot;ADR&quot;, 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 = {&quot;TYPE&quot;: (&quot;WORK&quot;, &quot;PREF&quot;, &quot;INTERNET&quot;,), }
-    workParams = {&quot;TYPE&quot;: (&quot;WORK&quot;, &quot;INTERNET&quot;,), }
</del><ins>+    preferredWorkParams = {&quot;TYPE&quot;: [&quot;WORK&quot;, &quot;PREF&quot;, &quot;INTERNET&quot;, ], }
+    workParams = {&quot;TYPE&quot;: [&quot;WORK&quot;, &quot;INTERNET&quot;, ], }
</ins><span class="cx">     params = preferredWorkParams
</span><span class="cx">     for emailAddress in record.fields.get(FieldName.emailAddresses, ()):
</span><del>-        addUniqueProperty(Property(&quot;EMAIL&quot;, emailAddress.encode(&quot;utf-8&quot;), params=params), ignoredParameters={&quot;TYPE&quot;: (&quot;PREF&quot;,)})
</del><ins>+        addUniqueProperty(Property(&quot;EMAIL&quot;, emailAddress.encode(&quot;utf-8&quot;), params=params), ignoredParameters={&quot;TYPE&quot;: [&quot;PREF&quot;, ]})
</ins><span class="cx">         params = workParams
</span><span class="cx"> 
</span><span class="cx">     # UNIMPLEMENTED:
</span></span></pre>
</div>
</div>

</body>
</html>