[CalendarServer-changes] [13636] CalendarServer/trunk/txdav/who/test/test_group_attendees.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Jun 13 06:36:18 PDT 2014


Revision: 13636
          http://trac.calendarserver.org//changeset/13636
Author:   gaya at apple.com
Date:     2014-06-13 06:36:18 -0700 (Fri, 13 Jun 2014)
Log Message:
-----------
test_groupChangeSpanningEvent -> test_groupChangeSmallerSpanningEvent, test_groupChangeLargerSpanningEvent

Modified Paths:
--------------
    CalendarServer/trunk/txdav/who/test/test_group_attendees.py

Modified: CalendarServer/trunk/txdav/who/test/test_group_attendees.py
===================================================================
--- CalendarServer/trunk/txdav/who/test/test_group_attendees.py	2014-06-13 12:38:54 UTC (rev 13635)
+++ CalendarServer/trunk/txdav/who/test/test_group_attendees.py	2014-06-13 13:36:18 UTC (rev 13636)
@@ -1048,7 +1048,7 @@
 
 
     @inlineCallbacks
-    def test_groupChangeSpanningEvent(self):
+    def test_groupChangeSmallerSpanningEvent(self):
         """
         Test that group attendee changes not applied to old recurring events
         """
@@ -1195,6 +1195,156 @@
         '''
 
     @inlineCallbacks
+    def test_groupChangeLargerSpanningEvent(self):
+        """
+        Test that group attendee changes not applied to old recurring events
+        """
+
+        data_put_1 = """BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+VERSION:2.0
+BEGIN:VEVENT
+DTSTAMP:20051222T205953Z
+CREATED:20060101T150000Z
+DTSTART:20120101T100000Z
+DURATION:PT1H
+RRULE:FREQ=DAILY;UNTIL=20240101T100000
+SUMMARY:event 1
+UID:event1 at ninevah.local
+ORGANIZER:MAILTO:user02 at example.com
+ATTENDEE:mailto:user02 at example.com
+ATTENDEE:MAILTO:group01 at example.com
+END:VEVENT
+END:VCALENDAR"""
+
+        data_get_1 = """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+BEGIN:VEVENT
+UID:event1 at ninevah.local
+DTSTART:20120101T100000Z
+DURATION:PT1H
+ATTENDEE;CN=User 02;EMAIL=user02 at example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01 at example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
+CREATED:20060101T150000Z
+ORGANIZER;CN=User 02;EMAIL=user02 at example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
+RRULE:FREQ=DAILY;UNTIL=20240101T100000
+SUMMARY:event 1
+END:VEVENT
+END:VCALENDAR
+"""
+
+        data_get_2 = """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+BEGIN:VEVENT
+UID:event1 at ninevah.local
+{start}DURATION:PT1H
+ATTENDEE;CN=User 02;EMAIL=user02 at example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01 at example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
+ATTENDEE;CN=User 01;EMAIL=user01 at example.com;MEMBER="urn:x-uid:20000000-0000-0000-0000-000000000001";PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000001
+CREATED:20060101T150000Z
+ORGANIZER;CN=User 02;EMAIL=user02 at example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
+{relatedTo}RRULE:FREQ=DAILY;UNTIL=20240101T100000
+SEQUENCE:2
+SUMMARY:event 1
+END:VEVENT
+END:VCALENDAR
+"""
+        data_get_3 = """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+BEGIN:VEVENT
+{uid}DTSTART:20120101T100000Z
+DURATION:PT1H
+ATTENDEE;CN=User 02;EMAIL=user02 at example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01 at example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
+CREATED:20060101T150000Z
+ORGANIZER;CN=User 02;EMAIL=user02 at example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
+{relatedTo}{rule}SEQUENCE:1
+SUMMARY:event 1
+END:VEVENT
+END:VCALENDAR
+"""
+
+        @inlineCallbacks
+        def expandedMembers(self, records=None):
+            yield None
+            returnValue(set())
+
+        unpatchedExpandedMembers = CalendarDirectoryRecordMixin.expandedMembers
+        self.patch(CalendarDirectoryRecordMixin, "expandedMembers", expandedMembers)
+
+        groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
+
+        calendar = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000002")
+        vcalendar = Component.fromString(data_put_1)
+        yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
+        yield self.commit()
+
+        cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000002")
+        vcalendar = yield cobj.component()
+        self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_1))
+
+        yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000001", 0)
+
+        self.patch(CalendarDirectoryRecordMixin, "expandedMembers", unpatchedExpandedMembers)
+
+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
+        yield self.commit()
+        self.assertEqual(len(wps), 1)
+        yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
+
+        cal = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000002")
+        cobjs = yield cal.objectResources()
+        for cobj in cobjs:
+            vcalendar = yield cobj.component()
+            for component in vcalendar.subcomponents():
+                if component.name() in ignoredComponents:
+                    continue
+                relatedTo = component.getProperty("RELATED-TO")
+                start = component.getProperty("DTSTART")
+                rule = component.getProperty("RRULE")
+                uid = component.getProperty("UID")
+                break
+
+            if cobj.name() == "data1.ics":
+                self.assertEqual(
+                    normalize_iCalStr(vcalendar),
+                    normalize_iCalStr(
+                        data_get_2.format(
+                            start=start,
+                            relatedTo=relatedTo,
+                        )
+                    )
+                )
+            else:
+                self.assertEqual(
+                    normalize_iCalStr(vcalendar),
+                    normalize_iCalStr(
+                        data_get_3.format(
+                            relatedTo=relatedTo,
+                            rule=rule,
+                            uid=uid
+                        )
+                    )
+                )
+
+        yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000001", 1)
+        #TODO: add some meaningful test
+        '''
+        cal = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000001")
+        cobjs = yield cal.objectResources()
+        for cobj in cobjs:
+            vcalendar = yield cobj.component()
+            print("vcalendar = %s" % (vcalendar,))
+        '''
+
+    @inlineCallbacks
     def test_groupRemovalFromDirectory(self):
         """
         Test that removing a group from the directory also removes the expanded attendees.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140613/633402d5/attachment-0001.html>


More information about the calendarserver-changes mailing list