[CalendarServer-changes] [7467] CalendarServer/branches/users/glyph/new-export/twistedcaldav/ datafilters/test/test_peruserdata.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon May 16 07:44:35 PDT 2011
Revision: 7467
http://trac.macosforge.org/projects/calendarserver/changeset/7467
Author: glyph at apple.com
Date: 2011-05-16 07:44:35 -0700 (Mon, 16 May 2011)
Log Message:
-----------
expose data for test_peruser_twousers public so that other tests can use it
Modified Paths:
--------------
CalendarServer/branches/users/glyph/new-export/twistedcaldav/datafilters/test/test_peruserdata.py
Modified: CalendarServer/branches/users/glyph/new-export/twistedcaldav/datafilters/test/test_peruserdata.py
===================================================================
--- CalendarServer/branches/users/glyph/new-export/twistedcaldav/datafilters/test/test_peruserdata.py 2011-05-16 14:44:23 UTC (rev 7466)
+++ CalendarServer/branches/users/glyph/new-export/twistedcaldav/datafilters/test/test_peruserdata.py 2011-05-16 14:44:35 UTC (rev 7467)
@@ -18,11 +18,7 @@
from twistedcaldav.ical import Component
from twistedcaldav.datafilters.peruserdata import PerUserDataFilter
-class PerUserDataFilterTestNotRecurring (twistedcaldav.test.util.TestCase):
-
- def test_public_noperuser(self):
-
- data = """BEGIN:VCALENDAR
+dataForTwoUsers = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
BEGIN:VEVENT
@@ -33,17 +29,35 @@
ATTENDEE:mailto:user2 at example.com
ORGANIZER;CN=User 01:mailto:user1 at example.com
END:VEVENT
+BEGIN:X-CALENDARSERVER-PERUSER
+UID:12345-67890
+X-CALENDARSERVER-PERUSER-UID:user01
+BEGIN:X-CALENDARSERVER-PERINSTANCE
+BEGIN:VALARM
+ACTION:DISPLAY
+DESCRIPTION:Test01
+TRIGGER;RELATED=START:-PT10M
+END:VALARM
+TRANSP:OPAQUE
+END:X-CALENDARSERVER-PERINSTANCE
+END:X-CALENDARSERVER-PERUSER
+BEGIN:X-CALENDARSERVER-PERUSER
+UID:12345-67890
+X-CALENDARSERVER-PERUSER-UID:user02
+BEGIN:X-CALENDARSERVER-PERINSTANCE
+BEGIN:VALARM
+ACTION:DISPLAY
+DESCRIPTION:Test02
+TRIGGER;RELATED=START:-PT10M
+END:VALARM
+TRANSP:TRANSPARENT
+END:X-CALENDARSERVER-PERINSTANCE
+END:X-CALENDARSERVER-PERUSER
END:VCALENDAR
""".replace("\n", "\r\n")
-
- for item in (data, Component.fromString(data),):
- self.assertEqual(str(PerUserDataFilter("user01").filter(item)), data)
- for item in (data, Component.fromString(data),):
- self.assertEqual(str(PerUserDataFilter("").filter(item)), data)
- def test_public_oneuser(self):
-
- data = """BEGIN:VCALENDAR
+
+resultForUser1 = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
BEGIN:VEVENT
@@ -53,22 +67,18 @@
ATTENDEE:mailto:user1 at example.com
ATTENDEE:mailto:user2 at example.com
ORGANIZER;CN=User 01:mailto:user1 at example.com
-END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
+TRANSP:OPAQUE
BEGIN:VALARM
ACTION:DISPLAY
-DESCRIPTION:Test
+DESCRIPTION:Test01
TRIGGER;RELATED=START:-PT10M
END:VALARM
-TRANSP:OPAQUE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
+END:VEVENT
END:VCALENDAR
""".replace("\n", "\r\n")
- result01 = """BEGIN:VCALENDAR
+
+
+resultForUser2 = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
BEGIN:VEVENT
@@ -78,16 +88,18 @@
ATTENDEE:mailto:user1 at example.com
ATTENDEE:mailto:user2 at example.com
ORGANIZER;CN=User 01:mailto:user1 at example.com
-TRANSP:OPAQUE
+TRANSP:TRANSPARENT
BEGIN:VALARM
ACTION:DISPLAY
-DESCRIPTION:Test
+DESCRIPTION:Test02
TRIGGER;RELATED=START:-PT10M
END:VALARM
END:VEVENT
END:VCALENDAR
""".replace("\n", "\r\n")
- result02 = """BEGIN:VCALENDAR
+
+
+resultForOtherUser = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
BEGIN:VEVENT
@@ -100,15 +112,33 @@
END:VEVENT
END:VCALENDAR
""".replace("\n", "\r\n")
+
+
+
+class PerUserDataFilterTestNotRecurring (twistedcaldav.test.util.TestCase):
+
+ def test_public_noperuser(self):
+ data = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER;CN=User 01:mailto:user1 at example.com
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
for item in (data, Component.fromString(data),):
- self.assertEqual(str(PerUserDataFilter("user01").filter(item)), result01)
+ self.assertEqual(str(PerUserDataFilter("user01").filter(item)), data)
for item in (data, Component.fromString(data),):
- self.assertEqual(str(PerUserDataFilter("user02").filter(item)), result02)
- for item in (data, Component.fromString(data),):
- self.assertEqual(str(PerUserDataFilter("").filter(item)), result02)
+ self.assertEqual(str(PerUserDataFilter("").filter(item)), data)
- def test_public_twousers(self):
+ def test_public_oneuser(self):
data = """BEGIN:VCALENDAR
VERSION:2.0
@@ -127,24 +157,12 @@
BEGIN:X-CALENDARSERVER-PERINSTANCE
BEGIN:VALARM
ACTION:DISPLAY
-DESCRIPTION:Test01
+DESCRIPTION:Test
TRIGGER;RELATED=START:-PT10M
END:VALARM
TRANSP:OPAQUE
END:X-CALENDARSERVER-PERINSTANCE
END:X-CALENDARSERVER-PERUSER
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user02
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-BEGIN:VALARM
-ACTION:DISPLAY
-DESCRIPTION:Test02
-TRIGGER;RELATED=START:-PT10M
-END:VALARM
-TRANSP:TRANSPARENT
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
END:VCALENDAR
""".replace("\n", "\r\n")
result01 = """BEGIN:VCALENDAR
@@ -160,7 +178,7 @@
TRANSP:OPAQUE
BEGIN:VALARM
ACTION:DISPLAY
-DESCRIPTION:Test01
+DESCRIPTION:Test
TRIGGER;RELATED=START:-PT10M
END:VALARM
END:VEVENT
@@ -176,38 +194,39 @@
ATTENDEE:mailto:user1 at example.com
ATTENDEE:mailto:user2 at example.com
ORGANIZER;CN=User 01:mailto:user1 at example.com
-TRANSP:TRANSPARENT
-BEGIN:VALARM
-ACTION:DISPLAY
-DESCRIPTION:Test02
-TRIGGER;RELATED=START:-PT10M
-END:VALARM
END:VEVENT
END:VCALENDAR
""".replace("\n", "\r\n")
- result03 = """BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890
-DTSTART:20080601T120000Z
-DTEND:20080601T130000Z
-ATTENDEE:mailto:user1 at example.com
-ATTENDEE:mailto:user2 at example.com
-ORGANIZER;CN=User 01:mailto:user1 at example.com
-END:VEVENT
-END:VCALENDAR
-""".replace("\n", "\r\n")
-
+
for item in (data, Component.fromString(data),):
self.assertEqual(str(PerUserDataFilter("user01").filter(item)), result01)
for item in (data, Component.fromString(data),):
self.assertEqual(str(PerUserDataFilter("user02").filter(item)), result02)
for item in (data, Component.fromString(data),):
- self.assertEqual(str(PerUserDataFilter("user03").filter(item)), result03)
- for item in (data, Component.fromString(data),):
- self.assertEqual(str(PerUserDataFilter("").filter(item)), result03)
+ self.assertEqual(str(PerUserDataFilter("").filter(item)), result02)
+
+ def test_public_twousers(self):
+ """
+ A component with data for 2 users can return results for either of the
+ two users, or for a third user who has no per-user data embedded in it.
+ """
+
+ for item in (dataForTwoUsers, Component.fromString(dataForTwoUsers),):
+ self.assertEqual(str(PerUserDataFilter("user01").filter(item)),
+ resultForUser1)
+ for item in (dataForTwoUsers, Component.fromString(dataForTwoUsers),):
+ self.assertEqual(str(PerUserDataFilter("user02").filter(item)),
+ resultForUser2)
+ for item in (dataForTwoUsers, Component.fromString(dataForTwoUsers),):
+ self.assertEqual(str(PerUserDataFilter("user03").filter(item)),
+ resultForOtherUser)
+ for item in (dataForTwoUsers, Component.fromString(dataForTwoUsers),):
+ self.assertEqual(str(PerUserDataFilter("").filter(item)),
+ resultForOtherUser)
+
+
+
class PerUserDataFilterTestRecurring (twistedcaldav.test.util.TestCase):
def test_public_noperuser(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110516/d5901d93/attachment.html>
More information about the calendarserver-changes
mailing list