[CalendarServer-changes] [8183] CalendarServer/branches/users/sagen/applepush/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Tue Oct 11 09:02:16 PDT 2011


Revision: 8183
          http://trac.macosforge.org/projects/calendarserver/changeset/8183
Author:   sagen at apple.com
Date:     2011-10-11 09:02:14 -0700 (Tue, 11 Oct 2011)
Log Message:
-----------
Removing stub classes from tests because we now test with the real db store.

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/applepush/twistedcaldav/applepush.py
    CalendarServer/branches/users/sagen/applepush/twistedcaldav/test/test_applepush.py

Modified: CalendarServer/branches/users/sagen/applepush/twistedcaldav/applepush.py
===================================================================
--- CalendarServer/branches/users/sagen/applepush/twistedcaldav/applepush.py	2011-10-11 15:35:58 UTC (rev 8182)
+++ CalendarServer/branches/users/sagen/applepush/twistedcaldav/applepush.py	2011-10-11 16:02:14 UTC (rev 8183)
@@ -116,7 +116,7 @@
             # Look up subscriptions for this key
             txn = self.store.newTransaction()
             subscriptions = (yield txn.apnSubscriptionsByKey(key))
-            yield txn.commit() # TODO: Glyph, needed?  No changes being made.
+            yield txn.commit()
 
             numSubscriptions = len(subscriptions)
             if numSubscriptions > 0:

Modified: CalendarServer/branches/users/sagen/applepush/twistedcaldav/test/test_applepush.py
===================================================================
--- CalendarServer/branches/users/sagen/applepush/twistedcaldav/test/test_applepush.py	2011-10-11 15:35:58 UTC (rev 8182)
+++ CalendarServer/branches/users/sagen/applepush/twistedcaldav/test/test_applepush.py	2011-10-11 16:02:14 UTC (rev 8183)
@@ -57,8 +57,7 @@
 
 
         # Add subscriptions
-        store = self.store # StubStore()
-        txn = store.newTransaction()
+        txn = self.store.newTransaction()
         token = "2d0d55cd7f98bcb81c6e24abcdc35168254c7846a43e2828b1ba5a8f82e219df"
         key1 = "/CalDAV/calendars.example.com/user01/calendar/"
         timestamp1 = 1000
@@ -72,8 +71,8 @@
 
         # Set up the service
         clock = Clock()
-        service = (yield ApplePushNotifierService.makeService(settings, store,
-            testConnectorClass=TestConnector, reactor=clock))
+        service = (yield ApplePushNotifierService.makeService(settings,
+            self.store, testConnectorClass=TestConnector, reactor=clock))
         self.assertEquals(set(service.providers.keys()), set(["CalDAV","CardDAV"]))
         self.assertEquals(set(service.feedbacks.keys()), set(["CalDAV","CardDAV"]))
 
@@ -107,7 +106,7 @@
 
         # Simulate an error
         errorData = struct.pack("!BBI", APNProviderProtocol.COMMAND_ERROR, 1, 1)
-        connector.receiveData(errorData)
+        yield connector.receiveData(errorData)
         clock.advance(301)
 
         # Prior to feedback, there are 2 subscriptions
@@ -152,56 +151,3 @@
 
     def write(self, data):
         self.data = data
-
-
-class StubStore(object):
-
-    def __init__(self):
-        self.subscriptions = []
-
-    def newTransaction(self):
-        return StubTransaction(self)
-
-
-class StubTransaction(object):
-
-    def __init__(self, store):
-        self.store = store
-
-    def apnSubscriptionsByKey(self, key):
-        matches = []
-        for subscription in self.store.subscriptions:
-            if subscription.key == key:
-                matches.append((subscription.token, subscription.guid))
-        return succeed(matches)
-
-    def apnSubscriptionsByToken(self, token):
-        matches = []
-        for subscription in self.store.subscriptions:
-            if subscription.token == token:
-                matches.append((subscription.key, subscription.timestamp,
-                    subscription.guid))
-        return succeed(matches)
-
-    def addAPNSubscription(self, token, key, timestamp, guid):
-        subscription = Subscription(token, key, timestamp, guid)
-        self.store.subscriptions.append(subscription)
-        return succeed(None)
-
-    def removeAPNSubscription(self, token, key):
-        for subscription in list(self.store.subscriptions):
-            if subscription.token == token and subscription.key == key:
-                self.store.subscriptions.remove(subscription)
-        return succeed(None)
-
-    def commit(self):
-        pass
-
-
-class Subscription(object):
-
-    def __init__(self, token, key, timestamp, guid):
-        self.token = token
-        self.key = key
-        self.timestamp = timestamp
-        self.guid = guid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111011/c861249f/attachment.html>


More information about the calendarserver-changes mailing list