[CalendarServer-changes] [9064] CalendarServer/branches/users/glyph/ipv6-client/twext/internet

source_changes at macosforge.org source_changes at macosforge.org
Fri Apr 13 11:44:35 PDT 2012


Revision: 9064
          http://trac.macosforge.org/projects/calendarserver/changeset/9064
Author:   glyph at apple.com
Date:     2012-04-13 11:44:35 -0700 (Fri, 13 Apr 2012)
Log Message:
-----------
a little more test refactoring, connect after failure (i.e. in disconnected state)

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/ipv6-client/twext/internet/adaptendpoint.py
    CalendarServer/branches/users/glyph/ipv6-client/twext/internet/test/test_adaptendpoint.py

Modified: CalendarServer/branches/users/glyph/ipv6-client/twext/internet/adaptendpoint.py
===================================================================
--- CalendarServer/branches/users/glyph/ipv6-client/twext/internet/adaptendpoint.py	2012-04-13 18:44:29 UTC (rev 9063)
+++ CalendarServer/branches/users/glyph/ipv6-client/twext/internet/adaptendpoint.py	2012-04-13 18:44:35 UTC (rev 9064)
@@ -77,7 +77,7 @@
 
 
     def connect(self):
-        pass
+        self.wrapper.startAttempt()
 
 
     def stopConnecting(self):

Modified: CalendarServer/branches/users/glyph/ipv6-client/twext/internet/test/test_adaptendpoint.py
===================================================================
--- CalendarServer/branches/users/glyph/ipv6-client/twext/internet/test/test_adaptendpoint.py	2012-04-13 18:44:29 UTC (rev 9063)
+++ CalendarServer/branches/users/glyph/ipv6-client/twext/internet/test/test_adaptendpoint.py	2012-04-13 18:44:35 UTC (rev 9064)
@@ -124,8 +124,8 @@
 
     def connectionSucceeds(self, addr=object()):
         """
-        The most recent connection attempt succeeds, returning the protocol
-        object produced by its success.
+        The most recent connection attempt succeeds, returning the L{ITransport}
+        provider produced by its success.
         """
         transport = RecordingTransport()
         attempt = self.endpoint.attempts[-1]
@@ -136,6 +136,13 @@
         return transport
 
 
+    def connectionFails(self, reason):
+        """
+        The most recent in-progress connection fails.
+        """
+        self.endpoint.attempts[-1].deferred.errback(reason)
+
+
     def test_connectStartsConnection(self):
         """
         When used with a successful endpoint, L{connect} will simulate all
@@ -174,7 +181,7 @@
         notified via C{clientConnectionFailed}.
         """
         why = Failure(RuntimeError())
-        self.endpoint.attempts[0].deferred.errback(why)
+        self.connectionFails(why)
         self.assertEquals(len(self.factory.fails), 1)
         self.assertIdentical(self.factory.fails[0].reason, why)
 
@@ -184,7 +191,6 @@
         If the L{IConnector} is told to C{disconnect} before an in-progress
         L{Deferred} from C{connect} has fired, it will cancel that L{Deferred}.
         """
-        self.connector = self.factory.starts[0]
         self.connector.disconnect()
         self.assertEqual(len(self.factory.fails), 1)
         self.assertTrue(self.factory.fails[0].reason.check(CancelledError))
@@ -206,8 +212,14 @@
         If the L{IConnector} is told to C{connect} after a connection attempt
         has failed, a new connection attempt is started.
         """
-        
+        why = Failure(ZeroDivisionError())
+        self.connectionFails(why)
+        self.connector.connect()
+        self.assertEqual(len(self.factory.starts), 2)
+        self.assertEqual(len(self.endpoint.attempts), 2)
+        self.connectionSucceeds()
 
 
 
 
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120413/557175b4/attachment.html>


More information about the calendarserver-changes mailing list