[CalendarServer-changes] [13562] CalendarServer/trunk/txdav/who
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 29 12:18:55 PDT 2014
Revision: 13562
http://trac.calendarserver.org//changeset/13562
Author: gaya at apple.com
Date: 2014-05-29 12:18:54 -0700 (Thu, 29 May 2014)
Log Message:
-----------
add tests for GroupCacher.groupsToRefresh()
Modified Paths:
--------------
CalendarServer/trunk/txdav/who/groups.py
CalendarServer/trunk/txdav/who/test/test_group_attendees.py
Modified: CalendarServer/trunk/txdav/who/groups.py
===================================================================
--- CalendarServer/trunk/txdav/who/groups.py 2014-05-29 19:06:07 UTC (rev 13561)
+++ CalendarServer/trunk/txdav/who/groups.py 2014-05-29 19:18:54 UTC (rev 13562)
@@ -391,10 +391,7 @@
"There are {count} group delegates", count=len(delegatedUIDs)
)
- attendeeGroupUIDs = set()
-
# Get groupUIDs for aoo group attendees
- # FIXME: this query does not have a unit test!
groupAttendee = schema.GROUP_ATTENDEE
gr = schema.GROUPS
rows = yield Select(
Modified: CalendarServer/trunk/txdav/who/test/test_group_attendees.py
===================================================================
--- CalendarServer/trunk/txdav/who/test/test_group_attendees.py 2014-05-29 19:06:07 UTC (rev 13561)
+++ CalendarServer/trunk/txdav/who/test/test_group_attendees.py 2014-05-29 19:18:54 UTC (rev 13562)
@@ -486,6 +486,9 @@
self.patch(CalendarDirectoryRecordMixin, "expandedMembers", expandedMembers)
groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
+ groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+ self.assertEqual(len(groupsToRefresh), 0)
+
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
self.assertEqual(len(wps), 0)
@@ -502,7 +505,10 @@
yield self.commit()
self.patch(CalendarDirectoryRecordMixin, "expandedMembers", unpatchedExpandedMembers)
-
+
+ groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+ self.assertEqual(len(groupsToRefresh), 1)
+
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
yield self.commit()
self.assertEqual(len(wps), 1)
@@ -618,6 +624,9 @@
self.patch(CalendarDirectoryRecordMixin, "expandedMembers", expandedMembers)
groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
+ groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+ self.assertEqual(len(groupsToRefresh), 0)
+
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
self.assertEqual(len(wps), 0)
@@ -638,6 +647,9 @@
self.patch(CalendarDirectoryRecordMixin, "expandedMembers", unpatchedExpandedMembers)
+ groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+ self.assertEqual(len(groupsToRefresh), 1)
+
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
yield self.commit()
self.assertEqual(len(wps), len(userRange))
@@ -717,6 +729,9 @@
yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
+ groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+ self.assertEqual(len(groupsToRefresh), 0)
+
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
if len(wps): # This is needed because the test currently fails and does actually create job items we have to wait for
yield self.commit()
@@ -816,6 +831,9 @@
yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
+ groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+ self.assertEqual(len(groupsToRefresh), 1)
+
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
yield self.commit()
self.assertEqual(len(wps), 1)
@@ -946,6 +964,9 @@
yield calendar.createCalendarObjectWithName("data1.ics", vcalendar)
yield self.commit()
+ groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+ self.assertEqual(len(groupsToRefresh), 1)
+
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
yield self.commit()
self.assertEqual(len(wps), 1)
@@ -1104,6 +1125,9 @@
# cache group
groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
+ groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+ self.assertEqual(len(groupsToRefresh), 3)
+
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000002")
yield self.commit()
self.assertEqual(len(wps), 1)
@@ -1113,7 +1137,7 @@
vcalendar = yield cobj.component()
self._assertICalStrEqual(vcalendar, data_get_1)
- # remove group run cacher again
+ # remove group members run cacher again
self.patch(DirectoryService, "recordWithUID", recordWithUID)
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000002")
@@ -1132,7 +1156,7 @@
self.assertTrue("STATUS:CANCELLED" in str(comp))
yield self.commit()
- # add group back, run cacher
+ # add group members back, run cacher
self.patch(DirectoryService, "recordWithUID", unpatchedRecordWithUID)
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000002")
@@ -1260,6 +1284,9 @@
# cache groups
groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
+ groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+ self.assertEqual(len(groupsToRefresh), 2)
+
wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000002")
yield self.commit()
self.assertEqual(len(wps), 1)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140529/b44fe4c3/attachment.html>
More information about the calendarserver-changes
mailing list