[CalendarServer-changes] [13373] CalendarServer/trunk/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Fri Apr 25 15:43:49 PDT 2014
Revision: 13373
http://trac.calendarserver.org//changeset/13373
Author: gaya at apple.com
Date: 2014-04-25 15:43:49 -0700 (Fri, 25 Apr 2014)
Log Message:
-----------
don't reconcile group attendees for old events when group changes
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/who/test/test_group_attendees.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2014-04-25 15:15:25 UTC (rev 13372)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2014-04-25 22:43:49 UTC (rev 13373)
@@ -1974,10 +1974,33 @@
update schema.GROUP_ATTENDEE
"""
if groupCUAToAttendeeMemberPropMap is None:
- if not hasattr(self, "_groupCUAToAttendeeMemberPropMap"):
+ # post processing.
+
+ # see if this event ends in the past
+ tr = schema.TIME_RANGE
+ rows = yield Select(
+ [Count(tr.CALENDAR_OBJECT_RESOURCE_ID)],
+ From=tr,
+ Where=(
+ tr.CALENDAR_OBJECT_RESOURCE_ID == self._resourceID).And(
+ tr.END_DATE > datetime.datetime.utcnow()
+ ),
+ ).on(self._txn)
+
+ if rows[0][0] == 0:
+ # delete group attendee rows and exit
+ ga = schema.GROUP_ATTENDEE
+ rows = yield Delete(
+ From=ga,
+ Where=ga.RESOURCE_ID == self._resourceID,
+ Return=[ga.GROUP_ID]
+ ).on(self._txn)
+ returnValue(bool(rows))
+
+ if hasattr(self, "_groupCUAToAttendeeMemberPropMap"):
+ groupCUAToAttendeeMemberPropMap = self._groupCUAToAttendeeMemberPropMap
+ else:
returnValue(False)
- else:
- groupCUAToAttendeeMemberPropMap = self._groupCUAToAttendeeMemberPropMap
changed = False
ga = schema.GROUP_ATTENDEE
@@ -2696,7 +2719,7 @@
yield self.updateDatabase(component, inserting=inserting)
- # update GROUP_ATTENNDEE rows using
+ # update GROUP_ATTENDEE table rows
yield self.updateGROUP_ATTENDEE()
# Post process managed attachments
Modified: CalendarServer/trunk/txdav/who/test/test_group_attendees.py
===================================================================
--- CalendarServer/trunk/txdav/who/test/test_group_attendees.py 2014-04-25 15:15:25 UTC (rev 13372)
+++ CalendarServer/trunk/txdav/who/test/test_group_attendees.py 2014-04-25 22:43:49 UTC (rev 13373)
@@ -23,7 +23,7 @@
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.trial import unittest
from twistedcaldav.config import config
-from twistedcaldav.ical import Component, normalize_iCalStr
+from twistedcaldav.ical import Component, normalize_iCalStr, ignoredComponents
from txdav.caldav.datastore.test.util import buildCalendarStore, populateCalendarsFrom, CommonCommonTests
from txdav.who.directory import CalendarDirectoryRecordMixin
from txdav.who.groups import GroupCacher
@@ -94,9 +94,25 @@
def _assertICalStrEqual(self, iCalStr1, iCalStr2):
+
+ def orderMemberValues(event):
+
+ for component in event.subcomponents():
+ if component.name() in ignoredComponents:
+ continue
+
+ # remove all values and add them again
+ # this is sort of a hack, better pycalendar has ordering
+ for attendeeProp in tuple(component.properties("ATTENDEE")):
+ if attendeeProp.hasParameter("MEMBER"):
+ parameterValues = tuple(attendeeProp.parameterValues("MEMBER"))
+ for paramterValue in parameterValues:
+ attendeeProp.removeParameterValue("MEMBER", paramterValue)
+ attendeeProp.setParameter("MEMBER", sorted(parameterValues))
+
self.assertEqual(
- normalize_iCalStr(iCalStr1),
- normalize_iCalStr(Component.fromString(iCalStr2)),
+ orderMemberValues(Component.fromString(normalize_iCalStr(iCalStr1))),
+ orderMemberValues(Component.fromString(normalize_iCalStr(iCalStr2)))
)
@@ -147,13 +163,13 @@
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000006", 0)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000007", 0)
- vcalendar1 = Component.fromString(data_put_1)
- yield calendar.createCalendarObjectWithName("data1.ics", vcalendar1)
+ vcalendar = Component.fromString(data_put_1)
+ yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar2 = yield cobj1.component()
- self._assertICalStrEqual(vcalendar2, data_get_1)
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self._assertICalStrEqual(vcalendar, data_get_1)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000006", 1)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000007", 1)
@@ -200,13 +216,13 @@
END:VCALENDAR
"""
- vcalendar1 = Component.fromString(data_put_1)
- yield calendar.createCalendarObjectWithName("data1.ics", vcalendar1)
+ vcalendar = Component.fromString(data_put_1)
+ yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar2 = yield cobj1.component()
- self.assertEqual(normalize_iCalStr(vcalendar2), normalize_iCalStr(data_get_1))
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_1))
@inlineCallbacks
@@ -251,13 +267,13 @@
END:VEVENT
END:VCALENDAR
"""
- vcalendar1 = Component.fromString(data_put_1)
- yield calendar.createCalendarObjectWithName("data1.ics", vcalendar1)
+ vcalendar = Component.fromString(data_put_1)
+ yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar1 = yield cobj1.component()
- self.assertEqual(normalize_iCalStr(vcalendar1), normalize_iCalStr(data_get_1))
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_1))
@inlineCallbacks
@@ -312,13 +328,13 @@
END:VCALENDAR
"""
- vcalendar1 = Component.fromString(data_put_1)
- yield calendar.createCalendarObjectWithName("data1.ics", vcalendar1)
+ vcalendar = Component.fromString(data_put_1)
+ yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar2 = yield cobj1.component()
- self._assertICalStrEqual(vcalendar2, data_get_1)
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self._assertICalStrEqual(vcalendar, data_get_1)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000006", 1)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000007", 1)
@@ -380,13 +396,13 @@
END:VEVENT
END:VCALENDAR"""
- vcalendar1 = Component.fromString(data_put_1)
- yield calendar.createCalendarObjectWithName("data1.ics", vcalendar1)
+ vcalendar = Component.fromString(data_put_1)
+ yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar2 = yield cobj1.component()
- self._assertICalStrEqual(vcalendar2, data_get_1)
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self._assertICalStrEqual(vcalendar, data_get_1)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000006", 1)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000007", 1)
@@ -397,8 +413,9 @@
@inlineCallbacks
def test_groupChange(self):
"""
- Test that group attendee changes are applied to existing resources.
+ Test that group attendee are changed when the group changes.
"""
+
data_put_1 = """BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Example Inc.//Example Calendar//EN
@@ -406,7 +423,7 @@
BEGIN:VEVENT
DTSTAMP:20051222T205953Z
CREATED:20060101T150000Z
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
SUMMARY:event 1
UID:event1 at ninevah.local
@@ -422,7 +439,7 @@
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VEVENT
UID:event1 at ninevah.local
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
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=GROUP;EMAIL=group01 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000001
@@ -439,7 +456,7 @@
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VEVENT
UID:event1 at ninevah.local
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
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=GROUP;EMAIL=group01 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000001
@@ -458,7 +475,7 @@
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VEVENT
UID:event1 at ninevah.local
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
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=GROUP;EMAIL=group01 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000001
@@ -483,54 +500,52 @@
self.assertEqual(len(wps), 0)
calendar = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000002")
- vcalendar1 = Component.fromString(data_put_1)
- yield calendar.createCalendarObjectWithName("data1.ics", vcalendar1)
+ vcalendar = Component.fromString(data_put_1)
+ yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000002")
- vcalendar2 = yield cobj1.component()
- self.assertEqual(normalize_iCalStr(vcalendar2), normalize_iCalStr(data_get_2))
+ 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_2))
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000001", 0)
yield self.commit()
self.patch(CalendarDirectoryRecordMixin, "expandedMembers", unpatchedExpandedMembers)
- groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
yield self.commit()
self.assertEqual(len(wps), 1)
yield wps[0].whenExecuted()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000002")
- vcalendar3 = yield cobj1.component()
- self.assertEqual(normalize_iCalStr(vcalendar3), normalize_iCalStr(data_get_3))
+ 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_3))
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000001", 1)
yield self.commit()
self.patch(CalendarDirectoryRecordMixin, "expandedMembers", expandedMembers)
- groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
yield self.commit()
self.assertEqual(len(wps), 1)
yield wps[0].whenExecuted()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000002")
- vcalendar3 = yield cobj1.component()
- self.assertEqual(normalize_iCalStr(vcalendar3), normalize_iCalStr(data_get_4))
+ 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_4))
- cal1 = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000001")
- cobjs = yield cal1.objectResources()
+ cal = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000001")
+ cobjs = yield cal.objectResources()
self.assertEqual(len(cobjs), 1)
- comp1 = yield cobjs[0].componentForUser()
- self.assertTrue("STATUS:CANCELLED" in str(comp1))
+ comp = yield cobjs[0].componentForUser()
+ self.assertTrue("STATUS:CANCELLED" in str(comp))
@inlineCallbacks
def test_multieventGroupChange(self):
"""
- Test that every event associated with a group chagnes when the group changes
+ Test that every event associated with a group changes when the group changes
"""
data_put_1 = """BEGIN:VCALENDAR
@@ -540,7 +555,7 @@
BEGIN:VEVENT
DTSTAMP:20051222T205953Z
CREATED:20060101T150000Z
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
SUMMARY:event {0}
UID:event{0}@ninevah.local
@@ -556,7 +571,7 @@
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VEVENT
UID:event{0}@ninevah.local
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
ATTENDEE;CN=User 0{0};EMAIL=user0{0}@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-00000000000{0}
ATTENDEE;CN=Group 01;CUTYPE=GROUP;EMAIL=group01 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000001
@@ -573,7 +588,7 @@
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VEVENT
UID:event{0}@ninevah.local
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
ATTENDEE;CN=User 0{0};EMAIL=user0{0}@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-00000000000{0}
ATTENDEE;CN=Group 01;CUTYPE=GROUP;EMAIL=group01 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000001
@@ -592,7 +607,7 @@
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VEVENT
UID:event{0}@ninevah.local
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
ATTENDEE;CN=User 0{0};EMAIL=user0{0}@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-00000000000{0}
ATTENDEE;CN=Group 01;CUTYPE=GROUP;EMAIL=group01 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000001
@@ -620,20 +635,19 @@
for i in userRange:
calendar = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-00000000000{0}".format(i))
- vcalendar1 = Component.fromString(data_put_1.format(i))
- yield calendar.createCalendarObjectWithName("data1.ics", vcalendar1)
+ vcalendar = Component.fromString(data_put_1.format(i))
+ yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-00000000000{0}".format(i))
- vcalendar2 = yield cobj1.component()
- self.assertEqual(normalize_iCalStr(vcalendar2), normalize_iCalStr(data_get_2.format(i)))
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-00000000000{0}".format(i))
+ vcalendar = yield cobj.component()
+ self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_2.format(i)))
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000001", 0)
yield self.commit()
self.patch(CalendarDirectoryRecordMixin, "expandedMembers", unpatchedExpandedMembers)
- groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
yield self.commit()
self.assertEqual(len(wps), len(userRange))
@@ -641,15 +655,14 @@
yield wp.whenExecuted()
for i in userRange:
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-00000000000{0}".format(i))
- vcalendar3 = yield cobj1.component()
- self.assertEqual(normalize_iCalStr(vcalendar3), normalize_iCalStr(data_get_3.format(i)))
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-00000000000{0}".format(i))
+ vcalendar = yield cobj.component()
+ self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_3.format(i)))
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000001", len(userRange))
yield self.commit()
self.patch(CalendarDirectoryRecordMixin, "expandedMembers", expandedMembers)
- groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
yield self.commit()
self.assertEqual(len(wps), len(userRange))
@@ -657,19 +670,132 @@
yield wp.whenExecuted()
for i in userRange:
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-00000000000{0}".format(i))
- vcalendar3 = yield cobj1.component()
- self.assertEqual(normalize_iCalStr(vcalendar3), normalize_iCalStr(data_get_4.format(i)))
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-00000000000{0}".format(i))
+ vcalendar = yield cobj.component()
+ self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_4.format(i)))
- cal1 = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000001")
- cobjs = yield cal1.objectResources()
+ cal = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000001")
+ cobjs = yield cal.objectResources()
self.assertEqual(len(cobjs), len(userRange))
for cobj in cobjs:
- comp1 = yield cobj.componentForUser()
- self.assertTrue("STATUS:CANCELLED" in str(comp1))
+ comp = yield cobj.componentForUser()
+ self.assertTrue("STATUS:CANCELLED" in str(comp))
@inlineCallbacks
+ def test_groupChangeOldEvent(self):
+ """
+ Test that group attendee changes not applied to old events
+ """
+
+ data_put_1 = """BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+VERSION:2.0
+BEGIN:VEVENT
+DTSTAMP:20051222T205953Z
+CREATED:20060101T150000Z
+DTSTART;TZID=US/Eastern:20240101T100000
+DURATION:PT1H
+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_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 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;TZID=US/Eastern:20240101T100000
+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=GROUP;EMAIL=group01 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7: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
+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
+DTSTART;TZID=US/Eastern:20140101T100000
+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=GROUP;EMAIL=group01 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7: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
+SEQUENCE:1
+SUMMARY:event 1
+END:VEVENT
+END:VCALENDAR
+"""
+
+ @inlineCallbacks
+ def expandedMembers(self, records=None):
+ yield None
+ returnValue(set())
+
+ 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()
+
+ wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
+ yield self.commit()
+ self.assertEqual(len(wps), 1)
+ yield wps[0].whenExecuted()
+
+ 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", 1)
+
+ vcalendar = Component.fromString(data_put_2)
+ yield cobj.setComponent(vcalendar)
+ yield self.commit()
+
+ self.patch(CalendarDirectoryRecordMixin, "expandedMembers", expandedMembers)
+
+ 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_2))
+
+ wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
+ self.assertEqual(len(wps), 0)
+
+
+ @inlineCallbacks
def test_groupRemovalFromDirectory(self):
"""
Test that removing a group from the directory also removes the expanded attendees.
@@ -692,7 +818,7 @@
BEGIN:VEVENT
DTSTAMP:20051222T205953Z
CREATED:20060101T150000Z
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
SUMMARY:event 1
UID:event1 at ninevah.local
@@ -710,7 +836,7 @@
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VEVENT
UID:event1 at ninevah.local
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
ATTENDEE;CN=User 01;EMAIL=user01 at example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
ATTENDEE;CN=Group 01;CUTYPE=GROUP;EMAIL=group01 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000001
@@ -732,7 +858,7 @@
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VEVENT
UID:event1 at ninevah.local
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
ATTENDEE;CN=User 01;EMAIL=user01 at example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
ATTENDEE;CN=Group 01;CUTYPE=GROUP;EMAIL=group01 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000001
@@ -755,16 +881,16 @@
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VEVENT
UID:event1 at ninevah.local
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
ATTENDEE;CN=User 01;EMAIL=user01 at example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
ATTENDEE;CN=Group 01;CUTYPE=GROUP;EMAIL=group01 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000001
ATTENDEE;CN=Group 02;CUTYPE=GROUP;EMAIL=group02 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000002
ATTENDEE;CN=Group 03;CUTYPE=GROUP;EMAIL=group03 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000003
+ATTENDEE;CN=User 06;EMAIL=user06 at example.com;MEMBER="urn:x-uid:20000000-0000-0000-0000-000000000002";PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000006
ATTENDEE;CN=User 07;EMAIL=user07 at example.com;MEMBER="urn:x-uid:20000000-0000-0000-0000-000000000002","urn:x-uid:20000000-0000-0000-0000-000000000003";PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000007
ATTENDEE;CN=User 08;EMAIL=user08 at example.com;MEMBER="urn:x-uid:20000000-0000-0000-0000-000000000002","urn:x-uid:20000000-0000-0000-0000-000000000003";PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000008
ATTENDEE;CN=User 09;EMAIL=user09 at example.com;MEMBER="urn:x-uid:20000000-0000-0000-0000-000000000003";PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000009
-ATTENDEE;CN=User 06;EMAIL=user06 at example.com;MEMBER="urn:x-uid:20000000-0000-0000-0000-000000000002";PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000006
CREATED:20060101T150000Z
ORGANIZER;CN=User 01;EMAIL=user01 at example.com:urn:x-uid:10000000-0000-0000-0000-000000000001
SEQUENCE:2
@@ -783,13 +909,13 @@
result = yield unpatchedRecordWithUID(self, uid)
returnValue(result)
- vcalendar1 = Component.fromString(data_put_1)
- yield calendar.createCalendarObjectWithName("data1.ics", vcalendar1)
+ vcalendar = Component.fromString(data_put_1)
+ yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar2 = yield cobj1.component()
- self._assertICalStrEqual(vcalendar2, data_get_1)
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self._assertICalStrEqual(vcalendar, data_get_1)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000006", 1)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000007", 1)
@@ -803,48 +929,46 @@
self.assertEqual(len(wps), 1)
yield wps[0].whenExecuted()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar3 = yield cobj1.component()
- self._assertICalStrEqual(vcalendar3, data_get_1)
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self._assertICalStrEqual(vcalendar, data_get_1)
# remove group run cacher again
self.patch(DirectoryService, "recordWithUID", recordWithUID)
- groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000002")
yield self.commit()
self.assertEqual(len(wps), 1)
yield wps[0].whenExecuted()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar4 = yield cobj1.component()
- self._assertICalStrEqual(vcalendar4, data_get_2)
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self._assertICalStrEqual(vcalendar, data_get_2)
- cal1 = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000006")
- cobjs = yield cal1.objectResources()
+ cal = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000006")
+ cobjs = yield cal.objectResources()
self.assertEqual(len(cobjs), 1)
- comp1 = yield cobjs[0].componentForUser()
- self.assertTrue("STATUS:CANCELLED" in str(comp1))
+ comp = yield cobjs[0].componentForUser()
+ self.assertTrue("STATUS:CANCELLED" in str(comp))
yield self.commit()
# add group back, run cacher
self.patch(DirectoryService, "recordWithUID", unpatchedRecordWithUID)
- groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000002")
self.assertEqual(len(wps), 1)
yield self.commit()
yield wps[0].whenExecuted()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar5 = yield cobj1.component()
- self._assertICalStrEqual(vcalendar5, data_get_3)
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self._assertICalStrEqual(vcalendar, data_get_3)
- cal1 = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000006")
- cobjs = yield cal1.objectResources()
+ cal = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000006")
+ cobjs = yield cal.objectResources()
self.assertEqual(len(cobjs), 1)
- comp1 = yield cobjs[0].componentForUser()
- self.assertFalse("STATUS:CANCELLED" in str(comp1))
+ comp = yield cobjs[0].componentForUser()
+ self.assertFalse("STATUS:CANCELLED" in str(comp))
yield self.commit()
@@ -871,7 +995,7 @@
BEGIN:VEVENT
DTSTAMP:20051222T205953Z
CREATED:20060101T150000Z
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
SUMMARY:event 1
UID:event1 at ninevah.local
@@ -888,7 +1012,7 @@
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VEVENT
UID:event1 at ninevah.local
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
ATTENDEE;CN=User 01;EMAIL=user01 at example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
ATTENDEE;CN=Group 02;CUTYPE=GROUP;EMAIL=group02 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000002
@@ -910,7 +1034,7 @@
BEGIN:VEVENT
DTSTAMP:20051222T205953Z
CREATED:20060101T150000Z
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
SUMMARY:event 1
UID:event1 at ninevah.local
@@ -926,7 +1050,7 @@
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VEVENT
UID:event1 at ninevah.local
-DTSTART;TZID=US/Eastern:20140101T100000
+DTSTART;TZID=US/Eastern:20240101T100000
DURATION:PT1H
ATTENDEE;CN=User 01;EMAIL=user01 at example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
ATTENDEE;CN=Group 02;CUTYPE=GROUP;EMAIL=group02 at example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:x-uid:20000000-0000-0000-0000-000000000002
@@ -941,13 +1065,13 @@
END:VCALENDAR
"""
- vcalendar1 = Component.fromString(data_put_1)
- yield calendar.createCalendarObjectWithName("data1.ics", vcalendar1)
+ vcalendar = Component.fromString(data_put_1)
+ yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar2 = yield cobj1.component()
- self._assertICalStrEqual(vcalendar2, data_get_1)
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self._assertICalStrEqual(vcalendar, data_get_1)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000006", 1)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000007", 1)
@@ -965,17 +1089,17 @@
self.assertEqual(len(wps), 1)
yield wps[0].whenExecuted()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar3 = yield cobj1.component()
- self._assertICalStrEqual(vcalendar3, data_get_1)
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self._assertICalStrEqual(vcalendar, data_get_1)
- vcalendar4 = Component.fromString(data_put_2)
- yield cobj1.setComponent(vcalendar4)
+ vcalendar = Component.fromString(data_put_2)
+ yield cobj.setComponent(vcalendar)
yield self.commit()
- cobj1 = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
- vcalendar5 = yield cobj1.component()
- self._assertICalStrEqual(vcalendar5, data_get_2)
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
+ vcalendar = yield cobj.component()
+ self._assertICalStrEqual(vcalendar, data_get_2)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000006", 1)
yield self._verifyObjectResourceCount("10000000-0000-0000-0000-000000000007", 1)
@@ -988,9 +1112,9 @@
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000003")
self.assertEqual(len(wps), 0)
- cal1 = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000009")
- cobjs = yield cal1.objectResources()
+ cal = yield self.calendarUnderTest(name="calendar", home="10000000-0000-0000-0000-000000000009")
+ cobjs = yield cal.objectResources()
self.assertEqual(len(cobjs), 1)
- comp1 = yield cobjs[0].componentForUser()
- self.assertTrue("STATUS:CANCELLED" in str(comp1))
+ comp = yield cobjs[0].componentForUser()
+ self.assertTrue("STATUS:CANCELLED" in str(comp))
yield self.commit()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140425/ccf055d6/attachment-0001.html>
More information about the calendarserver-changes
mailing list