[CalendarServer-changes] [7320] CalendarServer/trunk/contrib/performance/loadtest
source_changes at macosforge.org
source_changes at macosforge.org
Fri Apr 15 13:41:45 PDT 2011
Revision: 7320
http://trac.macosforge.org/projects/calendarserver/changeset/7320
Author: exarkun at twistedmatrix.com
Date: 2011-04-15 13:41:42 -0700 (Fri, 15 Apr 2011)
Log Message:
-----------
Fix Inviter profile so that it only tries to inviter users to events owned by its own account
Modified Paths:
--------------
CalendarServer/trunk/contrib/performance/loadtest/profiles.py
CalendarServer/trunk/contrib/performance/loadtest/test_profiles.py
Modified: CalendarServer/trunk/contrib/performance/loadtest/profiles.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/profiles.py 2011-04-15 15:59:26 UTC (rev 7319)
+++ CalendarServer/trunk/contrib/performance/loadtest/profiles.py 2011-04-15 20:41:42 UTC (rev 7320)
@@ -59,6 +59,16 @@
if cal.resourceType == calendarType]
+ def _isSelfAttendee(self, attendee):
+ """
+ Try to match one of the attendee's identifiers against one of
+ C{self._client}'s identifiers. Return C{True} if something matches,
+ C{False} otherwise.
+ """
+ return attendee.params[u'EMAIL'][0] == self._client.email[len('mailto:'):]
+
+
+
class CannotAddAttendee(Exception):
"""
Indicates no new attendees can be invited to a particular event.
@@ -143,10 +153,16 @@
if event is None:
continue
+ vevent = event.contents[u'vevent'][0]
+ organizer = vevent.contents.get('organizer', [None])[0]
+ if organizer is not None and not self._isSelfAttendee(organizer):
+ # This event was organized by someone else, don't try to invite someone to it.
+ continue
+
href = calendar.url + uuid
# Find out who might attend
- attendees = event.contents['vevent'][0].contents.get('attendee', [])
+ attendees = vevent.contents.get('attendee', [])
d = self._addAttendee(event, attendees)
d.addCallbacks(
@@ -189,7 +205,7 @@
# NEEDS-ACTION PARTSTAT.
attendees = vevent.contents['vevent'][0].contents.get('attendee', [])
for attendee in attendees:
- if attendee.params[u'EMAIL'][0] == self._client.email[len('mailto:'):]:
+ if self._isSelfAttendee(attendee):
if attendee.params[u'PARTSTAT'][0] == 'NEEDS-ACTION':
# XXX Base this on something real
delay = self.random.gauss(10, 2)
Modified: CalendarServer/trunk/contrib/performance/loadtest/test_profiles.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/test_profiles.py 2011-04-15 15:59:26 UTC (rev 7319)
+++ CalendarServer/trunk/contrib/performance/loadtest/test_profiles.py 2011-04-15 20:41:42 UTC (rev 7320)
@@ -334,7 +334,7 @@
If the inviter randomly selects a user which is already an
invitee on the event, a different user is added instead.
"""
- selfNumber = 13
+ selfNumber = 1
vevent, event, calendar, client = self._simpleAccount(
selfNumber, INVITED_EVENT)
@@ -376,7 +376,27 @@
self.assertEquals(len(attendees), 2)
+ def test_doNotInviteToSomeoneElsesEvent(self):
+ """
+ If there are events on our calendar which are being organized
+ by someone else, the inviter does not attempt to invite new
+ users to them.
+ """
+ selfNumber = 2
+ vevent, event, calendar, client = self._simpleAccount(
+ selfNumber, INVITED_EVENT)
+ inviter = Inviter(None, client, selfNumber)
+ # Try to send an invitation, but with only one event on the
+ # calendar, of which we are not the organizer. It should be
+ # unchanged afterwards.
+ inviter._invite()
+ attendees = event.vevent.contents[u'vevent'][0].contents[u'attendee']
+ self.assertEqual(len(attendees), 2)
+ self.assertEqual(attendees[0].params['CN'], [u'User 01'])
+ self.assertEqual(attendees[1].params['CN'], [u'User 02'])
+
+
class AccepterTests(TestCase):
"""
Tests for loadtest.profiles.Accepter.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110415/c8b7da25/attachment.html>
More information about the calendarserver-changes
mailing list