[CalendarServer-changes] [12048] CalendarServer/branches/users/sagen/groupcacher

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:20:37 PDT 2014


Revision: 12048
          http://trac.calendarserver.org//changeset/12048
Author:   gaya at apple.com
Date:     2013-12-09 15:56:05 -0800 (Mon, 09 Dec 2013)
Log Message:
-----------
add twext.who.test.test_groups.GroupAttendeeReconciliation.test_unknownPUT and fix

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/groupcacher/twext/who/test/test_groups.py
    CalendarServer/branches/users/sagen/groupcacher/txdav/caldav/datastore/sql.py

Modified: CalendarServer/branches/users/sagen/groupcacher/twext/who/test/test_groups.py
===================================================================
--- CalendarServer/branches/users/sagen/groupcacher/twext/who/test/test_groups.py	2013-12-09 23:45:37 UTC (rev 12047)
+++ CalendarServer/branches/users/sagen/groupcacher/twext/who/test/test_groups.py	2013-12-09 23:56:05 UTC (rev 12048)
@@ -343,6 +343,56 @@
 
 
     @inlineCallbacks
+    def test_unknownPUT(self):
+        """
+        Test that group attendee is expanded on PUT
+        """
+        calendar = yield self.calendarUnderTest(name="calendar", home="user01")
+
+        data_put_2 = """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 2
+UID:event2 at ninevah.local
+ORGANIZER:MAILTO:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;CUTYPE=GROUP:urn:uuid:groupUnknown
+END:VEVENT
+END:VCALENDAR"""
+
+        data_get_2 = """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+BEGIN:VEVENT
+UID:event2 at ninevah.local
+DTSTART;TZID=US/Eastern:20140101T100000
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01 at example.com;RSVP=TRUE:urn:uuid:user01
+ATTENDEE;CUTYPE=GROUP;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:uuid:groupUnknown
+CREATED:20060101T150000Z
+ORGANIZER;CN=User 01;EMAIL=user01 at example.com:urn:uuid:user01
+SUMMARY:event 2
+END:VEVENT
+END:VCALENDAR
+"""
+
+        vcalendar2 = Component.fromString(data_put_2)
+        cobj2 = yield calendar.createCalendarObjectWithName("data2.ics", vcalendar2)
+        yield self.commit()
+
+        cobj2 = yield self.calendarObjectUnderTest(name="data2.ics", calendar_name="calendar", home="user01")
+        vcalendar2 = yield cobj2.component()
+        self.assertEqual(normalize_iCalStr(vcalendar2), normalize_iCalStr(data_get_2))
+
+
+    @inlineCallbacks
     def test_primaryAttendeeInGroupPUT(self):
         """
         Test that primary attendee also in group remains primary

Modified: CalendarServer/branches/users/sagen/groupcacher/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/sagen/groupcacher/txdav/caldav/datastore/sql.py	2013-12-09 23:45:37 UTC (rev 12047)
+++ CalendarServer/branches/users/sagen/groupcacher/txdav/caldav/datastore/sql.py	2013-12-09 23:56:05 UTC (rev 12048)
@@ -1623,28 +1623,29 @@
         for groupGUID in groupGUIDs:
 
             groupRecord = yield self.directoryService().recordWithGUID(groupGUID)
-            members = yield expandedMembers(groupRecord)
-            membershipHashContent = hashlib.md5()
-            members = yield expandedMembers(groupRecord)
-            individualGUIDs = sorted([member.guid for member in members])
-            for individualGUID in individualGUIDs:
-                membershipHashContent.update(str(individualGUID))
-            membershipHash = membershipHashContent.hexdigest()
+            if groupRecord:
+                members = yield expandedMembers(groupRecord)
+                membershipHashContent = hashlib.md5()
+                members = yield expandedMembers(groupRecord)
+                individualGUIDs = sorted([member.guid for member in members])
+                for individualGUID in individualGUIDs:
+                    membershipHashContent.update(str(individualGUID))
+                membershipHash = membershipHashContent.hexdigest()
 
-            # associate group ID with self
-            groupID, name, membershipHash = yield self._txn.groupByGUID(groupGUID)
-            try:
-                groupAttendee = schema.GROUP_ATTENDEE
-                yield Insert({
-                    groupAttendee.RESOURCE_ID: self._resourceID,
-                    groupAttendee.GROUP_ID: groupID,
-                    groupAttendee.MEMBERSHIP_HASH: membershipHash,
-                })
-            except AllRetriesFailed:
-                pass
+                # associate group ID with self
+                groupID, name, membershipHash = yield self._txn.groupByGUID(groupGUID)
+                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
-            component.expandGroupAttendee(groupGUID, individualGUIDs, self.directoryService().recordWithCalendarUserAddress)
+                # get members
+                component.expandGroupAttendee(groupGUID, individualGUIDs, self.directoryService().recordWithCalendarUserAddress)
 
 
     def validCalendarDataCheck(self, component, inserting): #@UnusedVariable
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/a8394093/attachment.html>


More information about the calendarserver-changes mailing list