<!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>[13304] CalendarServer/trunk/txdav</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/13304">13304</a></dd>
<dt>Author</dt> <dd>gaya@apple.com</dd>
<dt>Date</dt> <dd>2014-04-16 17:26:27 -0700 (Wed, 16 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>update group attendees after group change</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktxdavcaldavdatastoresqlpy">CalendarServer/trunk/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavwhogroupspy">CalendarServer/trunk/txdav/who/groups.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_group_attendeespy">CalendarServer/trunk/txdav/who/test/test_group_attendees.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py (13303 => 13304)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-04-16 20:47:22 UTC (rev 13303)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-04-17 00:26:27 UTC (rev 13304)
</span><span class="lines">@@ -1915,7 +1915,7 @@
</span><span class="cx">             yield component.normalizeCalendarUserAddresses(normalizationLookup, self.directoryService().recordWithCalendarUserAddress)
</span><span class="cx"> 
</span><span class="cx">             # Expand groups
</span><del>-            yield self.expandGroupAttendees(component)
</del><ins>+            yield self.expandGroupAttendees(component, inserting)
</ins><span class="cx"> 
</span><span class="cx">             # Valid attendee list size check
</span><span class="cx">             yield self.validAttendeeListSizeCheck(component, inserting)
</span><span class="lines">@@ -1933,12 +1933,12 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def expandGroupAttendees(self, component):
</del><ins>+    def expandGroupAttendees(self, component, inserting):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Expand group attendees
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         if not config.Scheduling.Options.AllowGroupAsAttendee:
</span><del>-            return
</del><ins>+            returnValue(None)
</ins><span class="cx"> 
</span><span class="cx">         attendeeProps = component.getAllAttendeeProperties()
</span><span class="cx">         groupCUAs = set([
</span><span class="lines">@@ -1951,33 +1951,35 @@
</span><span class="cx">             if groupRecord:
</span><span class="cx">                 members = yield groupRecord.expandedMembers()
</span><span class="cx"> 
</span><del>-                # calculate hash
-                memberUIDs = sorted([member.uid for member in members])
-                membershipHashContent = hashlib.md5()
-                for memberUID in memberUIDs:
-                    membershipHashContent.update(memberUID)
-                membershipHash = membershipHashContent.hexdigest()
-
-                # associate group ID with self
-                groupID, _ignore_name, membershipHash, _ignore_modDate = yield self._txn.groupByUID(groupRecord.uid)
-                try:
-                    groupAttendee = schema.GROUP_ATTENDEE
-                    yield Insert({
-                        groupAttendee.RESOURCE_ID: self._resourceID,
-                        groupAttendee.GROUP_ID: groupID,
-                        groupAttendee.MEMBERSHIP_HASH: membershipHash,
-                    })
-                except AllRetriesFailed:
-                    pass
-
-                # get members
</del><ins>+                # add group attendees
</ins><span class="cx">                 yield component.expandGroupAttendee(
</span><span class="cx">                     groupRecord.canonicalCalendarUserAddress(),
</span><span class="cx">                     set([member.canonicalCalendarUserAddress() for member in members]),
</span><span class="cx">                     self.directoryService().recordWithCalendarUserAddress
</span><span class="cx">                 )
</span><span class="cx"> 
</span><ins>+                # tie event to group cacher
+                if not inserting:
+                    # calculate hash
+                    memberUIDs = sorted([member.uid for member in members])
+                    membershipHashContent = hashlib.md5()
+                    for memberUID in memberUIDs:
+                        membershipHashContent.update(memberUID)
+                    membershipHash = membershipHashContent.hexdigest()
</ins><span class="cx"> 
</span><ins>+                    # associate group ID with self
+                    groupID, _ignore_name, membershipHash, _ignore_modDate = yield self._txn.groupByUID(groupRecord.uid)
+                    try:
+                        groupAttendee = schema.GROUP_ATTENDEE
+                        yield Insert({
+                            groupAttendee.RESOURCE_ID: self._resourceID,
+                            groupAttendee.GROUP_ID: groupID,
+                            groupAttendee.MEMBERSHIP_HASH: membershipHash,
+                            }).on(self._txn)
+                    except AllRetriesFailed:
+                        pass
+
+
</ins><span class="cx">     def validCalendarDataCheck(self, component, inserting):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Check that the calendar data is valid iCalendar.
</span><span class="lines">@@ -2632,6 +2634,10 @@
</span><span class="cx"> 
</span><span class="cx">         yield self.updateDatabase(component, inserting=inserting)
</span><span class="cx"> 
</span><ins>+        # add GROUP_ATTENNDEE rows using just created _resourceID
+        if inserting:
+            yield self.expandGroupAttendees(component, False)
+
</ins><span class="cx">         # Post process managed attachments
</span><span class="cx">         if internal_state in (
</span><span class="cx">             ComponentUpdateState.NORMAL,
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhogroupspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/groups.py (13303 => 13304)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/groups.py        2014-04-16 20:47:22 UTC (rev 13303)
+++ CalendarServer/trunk/txdav/who/groups.py        2014-04-17 00:26:27 UTC (rev 13304)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> from twext.enterprise.jobqueue import WorkItem, PeerConnectionPool
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx"> from txdav.common.datastore.sql_tables import schema
</span><ins>+from txdav.caldav.datastore.sql import Calendar
</ins><span class="cx"> import datetime
</span><span class="cx"> import hashlib
</span><span class="cx"> 
</span><span class="lines">@@ -160,7 +161,7 @@
</span><span class="cx"> ):
</span><span class="cx"> 
</span><span class="cx">     group = property(
</span><del>-        lambda self: &quot;{0}, {1}&quot;.format(self.groupID, self.eventID)
</del><ins>+        lambda self: &quot;{0}, {1}&quot;.format(self.groupID, self.resourceID)
</ins><span class="cx">     )
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -169,39 +170,46 @@
</span><span class="cx">         # Delete all other work items for this group
</span><span class="cx">         yield Delete(
</span><span class="cx">             From=self.table,
</span><del>-            Where=((self.table.GROUP_ID == self.self.groupID).And(
-                self.table.RESOURCE_ID == self.self.eventID)
</del><ins>+            Where=((self.table.GROUP_ID == self.groupID).And(
+                self.table.RESOURCE_ID == self.resourceID)
</ins><span class="cx">             )
</span><span class="cx">         ).on(self.transaction)
</span><span class="cx"> 
</span><del>-        # get calendar Object
-        calObject = schema.CALENDAR_OBJECT
</del><ins>+        # get calendar id
+        co = schema.CALENDAR_OBJECT
</ins><span class="cx">         rows = yield Select(
</span><del>-                [calObject.CALENDAR_RESOURCE_ID, ],
-                From=calObject,
-                Where=calObject.RESOURCE_ID == self.eventID,
</del><ins>+                [co.CALENDAR_RESOURCE_ID, ],
+                From=co,
+                Where=co.RESOURCE_ID == self.resourceID,
</ins><span class="cx">         ).on(self.transaction)
</span><ins>+        calendarID = rows[0][0]
</ins><span class="cx"> 
</span><del>-        calendarID = rows[0][0]
-        calendarHome = (yield self.Calendar._ownerHomeWithResourceID.on(
</del><ins>+        # get home id
+        calendarHomeID = (yield Calendar._ownerHomeWithResourceID.on(
</ins><span class="cx">             self.transaction, resourceID=calendarID)
</span><span class="cx">         )[0][0]
</span><span class="cx"> 
</span><ins>+        # get db objects
+        calendarHome = yield self.transaction.calendarHomeWithResourceID(calendarHomeID)
</ins><span class="cx">         calendar = yield calendarHome.childWithID(calendarID)
</span><del>-        calendarObject = yield calendar.objectResourceWithID(self.eventID)
</del><ins>+        calendarObject = yield calendar.objectResourceWithID(self.resourceID)
+        component = yield calendarObject.component()
</ins><span class="cx"> 
</span><del>-        # get group individual UIDs
-        groupMemember = schema.GROUP_MEMBERSHIP
-        rows = yield Select(
-                [groupMemember.MEMBER_GUID, ],
-                From=groupMemember,
-                Where=groupMemember.GROUP_ID == self.groupID,
-        ).on(self.transaction)
-        memberGUIDs = [row[0] for row in rows]
</del><ins>+        # TODO: Check performance because:
+        #    1) if the component is changed then expandGroupAttendee() will be called again to validate
+        #    2) The group and members are in the group cache so could use them here
</ins><span class="cx"> 
</span><del>-        component = yield calendarObject.component()
-        changed = component.expandGroupAttendee(self.groupGUID, memberGUIDs, self.directoryService().recordWithCalendarUserAddress)
</del><ins>+        # get group record and members
+        groupUID, _ignore_name, _ignore_membershipHash = yield self.transaction.groupByID(self.groupID)
+        groupRecord = yield self.transaction.directoryService().recordWithUID(groupUID)
+        members = yield groupRecord.expandedMembers() if groupRecord else set()
</ins><span class="cx"> 
</span><ins>+        # expand
+        changed = yield component.expandGroupAttendee(
+            groupRecord.canonicalCalendarUserAddress(),
+            set([member.canonicalCalendarUserAddress() for member in members]),
+            self.transaction.directoryService().recordWithCalendarUserAddress
+        )
</ins><span class="cx">         if changed:
</span><span class="cx">             yield calendarObject.setComponent(component)
</span><span class="cx"> 
</span><span class="lines">@@ -319,9 +327,12 @@
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def refreshGroup(self, txn, groupUID):
</span><del>-        # Does the work of a per-group refresh work item
-        # Faults in the flattened membership of a group, as UIDs
-        # and updates the GROUP_MEMBERSHIP table
</del><ins>+        &quot;&quot;&quot;
+            Does the work of a per-group refresh work item
+            Faults in the flattened membership of a group, as UIDs
+            and updates the GROUP_MEMBERSHIP table
+            WorkProposals are returned for tests
+        &quot;&quot;&quot;
</ins><span class="cx">         self.log.debug(&quot;Faulting in group: {g}&quot;, g=groupUID)
</span><span class="cx">         record = (yield self.directory.recordWithUID(groupUID))
</span><span class="cx">         if record is None:
</span><span class="lines">@@ -357,9 +368,11 @@
</span><span class="cx">                     newMemberUIDs.add(member.uid)
</span><span class="cx">                 yield self.synchronizeMembers(txn, groupID, newMemberUIDs)
</span><span class="cx"> 
</span><del>-            yield self.scheduleEventReconciliations(txn, groupID, groupUID)
</del><ins>+            wps = yield self.scheduleEventReconciliations(txn, groupID)
</ins><span class="cx"> 
</span><ins>+        returnValue(wps)
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def synchronizeMembers(self, txn, groupID, newMemberUIDs):
</span><span class="cx">         numRemoved = numAdded = 0
</span><span class="lines">@@ -400,10 +413,11 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def scheduleEventReconciliations(self, txn, groupID, groupUID):
</del><ins>+    def scheduleEventReconciliations(self, txn, groupID):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Find all events who have this groupID as an attendee and create
</span><span class="cx">         work items for them.
</span><ins>+        returns: WorkProposal list
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         groupAttendee = schema.GROUP_ATTENDEE
</span><span class="cx">         rows = yield Select(
</span><span class="lines">@@ -413,6 +427,7 @@
</span><span class="cx">         ).on(txn)
</span><span class="cx">         eventIDs = [row[0] for row in rows]
</span><span class="cx"> 
</span><ins>+        wps = []
</ins><span class="cx">         for eventID in eventIDs:
</span><span class="cx"> 
</span><span class="cx">             notBefore = (
</span><span class="lines">@@ -421,21 +436,23 @@
</span><span class="cx">             )
</span><span class="cx">             log.debug(
</span><span class="cx">                 &quot;scheduling group reconciliation for &quot;
</span><del>-                &quot;({eventID}, {groupID}, {groupUID}): {when}&quot;,
-                eventID=eventID,
</del><ins>+                &quot;({resourceID}, {groupID},): {when}&quot;,
+                resourceID=eventID,
</ins><span class="cx">                 groupID=groupID,
</span><del>-                groupUID=groupUID,
-                when=notBefore)
</del><ins>+                when=notBefore
+            )
</ins><span class="cx"> 
</span><del>-            yield txn.enqueue(
</del><ins>+            wp = yield txn.enqueue(
</ins><span class="cx">                 GroupAttendeeReconciliationWork,
</span><del>-                eventID=eventID,
</del><ins>+                resourceID=eventID,
</ins><span class="cx">                 groupID=groupID,
</span><del>-                groupUID=groupUID,
</del><span class="cx">                 notBefore=notBefore
</span><span class="cx">             )
</span><ins>+            wps.append(wp)
</ins><span class="cx"> 
</span><ins>+        returnValue(tuple(wps))
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def groupsToRefresh(self, txn):
</span><span class="cx">         delegatedUIDs = set((yield txn.allGroupDelegates()))
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_group_attendeespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_group_attendees.py (13303 => 13304)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_group_attendees.py        2014-04-16 20:47:22 UTC (rev 13303)
+++ CalendarServer/trunk/txdav/who/test/test_group_attendees.py        2014-04-17 00:26:27 UTC (rev 13304)
</span><span class="lines">@@ -19,11 +19,13 @@
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx"> from twext.who.test.test_xml import xmlService
</span><del>-from twisted.internet.defer import inlineCallbacks
</del><ins>+from twisted.internet.defer import inlineCallbacks, returnValue
</ins><span class="cx"> from twisted.trial import unittest
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="cx"> from twistedcaldav.ical import Component, normalize_iCalStr
</span><span class="cx"> from txdav.caldav.datastore.test.util import buildCalendarStore, populateCalendarsFrom, CommonCommonTests
</span><ins>+from txdav.who.directory import CalendarDirectoryRecordMixin
+from txdav.who.groups import GroupCacher
</ins><span class="cx"> from txdav.who.util import directoryFromConfig
</span><span class="cx"> import os
</span><span class="cx"> 
</span><span class="lines">@@ -71,6 +73,9 @@
</span><span class="cx">         &quot;10000000-0000-0000-0000-000000000001&quot; : {
</span><span class="cx">             &quot;calendar&quot; : {}
</span><span class="cx">         },
</span><ins>+        &quot;10000000-0000-0000-0000-000000000002&quot; : {
+            &quot;calendar&quot; : {}
+        },
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -337,3 +342,115 @@
</span><span class="cx">         cobj1 = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</span><span class="cx">         vcalendar2 = yield cobj1.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar2), normalize_iCalStr(data_get_1))
</span><ins>+
+
+    @inlineCallbacks
+    def test_groupChange(self):
+        &quot;&quot;&quot;
+        Test that group attendee is expanded on PUT
+        &quot;&quot;&quot;
+        data_put_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+VERSION:2.0
+BEGIN:VEVENT
+DTSTAMP:20051222T205953Z
+CREATED:20060101T150000Z
+DTSTART;TZID=US/Eastern:20140101T100000
+DURATION:PT1H
+SUMMARY:event 1
+UID:event1@ninevah.local
+ORGANIZER:MAILTO:user02@example.com
+ATTENDEE:mailto:user02@example.com
+ATTENDEE:MAILTO:group01@example.com
+END:VEVENT
+END:VCALENDAR&quot;&quot;&quot;
+
+        data_get_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+BEGIN:VEVENT
+UID:event1@ninevah.local
+DTSTART;TZID=US/Eastern:20140101T100000
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:uuid:10000000-0000-0000-0000-000000000001
+ATTENDEE;CN=Group 02;CUTYPE=GROUP;EMAIL=group02@example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:uuid:20000000-0000-0000-0000-000000000002
+CREATED:20060101T150000Z
+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:uuid:10000000-0000-0000-0000-000000000001
+SUMMARY:event 1
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+        data_get_2 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+BEGIN:VEVENT
+UID:event1@ninevah.local
+DTSTART;TZID=US/Eastern:20140101T100000
+DURATION:PT1H
+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:uuid:10000000-0000-0000-0000-000000000002
+ATTENDEE;CN=Group 01;CUTYPE=GROUP;EMAIL=group01@example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:uuid:20000000-0000-0000-0000-000000000001
+CREATED:20060101T150000Z
+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:uuid:10000000-0000-0000-0000-000000000002
+SUMMARY:event 1
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+        data_get_3 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+BEGIN:VEVENT
+UID:event1@ninevah.local
+DTSTART;TZID=US/Eastern:20140101T100000
+DURATION:PT1H
+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:uuid:10000000-0000-0000-0000-000000000002
+ATTENDEE;CN=Group 01;CUTYPE=GROUP;EMAIL=group01@example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:uuid:20000000-0000-0000-0000-000000000001
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:uuid:20000000-0000-0000-0000-000000000001&quot;;PARTSTAT=NEEDS-ACTION:urn:uuid:10000000-0000-0000-0000-000000000001
+CREATED:20060101T150000Z
+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:uuid:10000000-0000-0000-0000-000000000002
+SUMMARY:event 1
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+        #TODO: should User 01 have SCHEDULE-STATUS=3.7 ?
+
+
+        @inlineCallbacks
+        def expandedMembers(self, records=None):
+            yield None
+            returnValue(set())
+
+        unpatchedExpandedMembers = CalendarDirectoryRecordMixin.expandedMembers
+        self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, expandedMembers)
+
+        groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
+        self.assertEqual(set(wps), set())
+
+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
+        vcalendar1 = Component.fromString(data_put_1)
+        yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar1)
+        yield self.commit()
+
+        cobj1 = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
+        vcalendar2 = yield cobj1.component()
+        self.assertEqual(normalize_iCalStr(vcalendar2), normalize_iCalStr(data_get_2))
+
+        self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, unpatchedExpandedMembers)
+
+        groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
+        yield self.commit()
+        self.assertEqual(len(wps), 1)
+        for wp in wps:
+            yield wp.whenExecuted()
+
+        cobj1 = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
+        vcalendar3 = yield cobj1.component()
+        self.assertEqual(normalize_iCalStr(vcalendar3), normalize_iCalStr(data_get_3))
</ins></span></pre>
</div>
</div>

</body>
</html>