[CalendarServer-changes] [11941] CalendarServer/trunk/calendarserver/push/test/test_notifier.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:23:14 PDT 2014
Revision: 11941
http://trac.calendarserver.org//changeset/11941
Author: sagen at apple.com
Date: 2013-11-13 12:03:22 -0800 (Wed, 13 Nov 2013)
Log Message:
-----------
Fix the shutdown race condition within the notifier unit tests
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/push/test/test_notifier.py
Modified: CalendarServer/trunk/calendarserver/push/test/test_notifier.py
===================================================================
--- CalendarServer/trunk/calendarserver/push/test/test_notifier.py 2013-11-13 19:12:56 UTC (rev 11940)
+++ CalendarServer/trunk/calendarserver/push/test/test_notifier.py 2013-11-13 20:03:22 UTC (rev 11941)
@@ -18,14 +18,13 @@
from calendarserver.push.notifier import PushDistributor
from calendarserver.push.notifier import getPubSubAPSConfiguration
from calendarserver.push.notifier import PushNotificationWork
-from twisted.internet.defer import inlineCallbacks, succeed
+from twisted.internet.defer import inlineCallbacks, succeed, gatherResults
from twistedcaldav.config import ConfigDict
from txdav.common.datastore.test.util import populateCalendarsFrom
from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE
from calendarserver.push.util import PushPriority
from txdav.idav import ChangeCategory
-
class StubService(object):
def __init__(self):
self.reset()
@@ -97,9 +96,9 @@
def enqueue(self, transaction, pushID, dataChangedTimestamp=None,
priority=None):
self.history.append((pushID, priority))
+ return(succeed(None))
-
class PushNotificationWorkTests(StoreTestCase):
@inlineCallbacks
@@ -124,27 +123,32 @@
pushDistributor.reset()
txn = self._sqlCalendarStore.newTransaction()
- wp = (yield txn.enqueue(PushNotificationWork,
+ proposals = []
+ wp = txn.enqueue(PushNotificationWork,
pushID="/CalDAV/localhost/bar/",
priority=PushPriority.high.value
- ))
- wp = (yield txn.enqueue(PushNotificationWork,
+ )
+ proposals.append(wp.whenExecuted())
+ wp = txn.enqueue(PushNotificationWork,
pushID="/CalDAV/localhost/bar/",
priority=PushPriority.high.value
- ))
- wp = (yield txn.enqueue(PushNotificationWork,
+ )
+ proposals.append(wp.whenExecuted())
+ wp = txn.enqueue(PushNotificationWork,
pushID="/CalDAV/localhost/bar/",
priority=PushPriority.high.value
- ))
+ )
+ proposals.append(wp.whenExecuted())
# Enqueue a different pushID to ensure those are not grouped with
# the others:
- wp = (yield txn.enqueue(PushNotificationWork,
+ wp = txn.enqueue(PushNotificationWork,
pushID="/CalDAV/localhost/baz/",
priority=PushPriority.high.value
- ))
+ )
+ proposals.append(wp.whenExecuted())
yield txn.commit()
- yield wp.whenExecuted()
+ yield gatherResults(proposals)
self.assertEquals(set(pushDistributor.history),
set([("/CalDAV/localhost/bar/", PushPriority.high),
("/CalDAV/localhost/baz/", PushPriority.high)]))
@@ -153,20 +157,24 @@
# enqueuing low, medium, and high notifications
pushDistributor.reset()
txn = self._sqlCalendarStore.newTransaction()
- wp = (yield txn.enqueue(PushNotificationWork,
+ proposals = []
+ wp = txn.enqueue(PushNotificationWork,
pushID="/CalDAV/localhost/bar/",
priority=PushPriority.low.value
- ))
- wp = (yield txn.enqueue(PushNotificationWork,
+ )
+ proposals.append(wp.whenExecuted())
+ wp = txn.enqueue(PushNotificationWork,
pushID="/CalDAV/localhost/bar/",
priority=PushPriority.high.value
- ))
- wp = (yield txn.enqueue(PushNotificationWork,
+ )
+ proposals.append(wp.whenExecuted())
+ wp = txn.enqueue(PushNotificationWork,
pushID="/CalDAV/localhost/bar/",
priority=PushPriority.medium.value
- ))
+ )
+ proposals.append(wp.whenExecuted())
yield txn.commit()
- yield wp.whenExecuted()
+ yield gatherResults(proposals)
self.assertEquals(pushDistributor.history,
[("/CalDAV/localhost/bar/", PushPriority.high)])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/84c5fa22/attachment.html>
More information about the calendarserver-changes
mailing list