#NEWLINE# def testClientRetransmission( self ) : #NEWLINE# #INDENT# 'Test that client retransmits failed messages.' #NEWLINE# fail = True #NEWLINE# num_messages = 10 #NEWLINE# def FlakyServer( req , timeout = None ) : #NEWLINE# #INDENT# if ( ( not fail ) or ( 'server.pem' in req . get_full_url ( ) ) ) : #NEWLINE# #INDENT# return self . UrlMock ( req , num_messages = num_messages ) #NEWLINE# #UNINDENT# raise urllib2 . HTTPError ( url = None , code = 500 , msg = None , hdrs = None , fp = None ) #NEWLINE# #UNINDENT# with utils . Stubber ( urllib2 , 'urlopen' , FlakyServer ) : #NEWLINE# #INDENT# self . SendToServer ( ) #NEWLINE# status = self . client_communicator . RunOnce ( ) #NEWLINE# self . assertEqual ( status . code , 500 ) #NEWLINE# self . assertEqual ( len ( self . messages ) , 0 ) #NEWLINE# fail = False #NEWLINE# self . assertEqual ( self . client_communicator . client_worker . InQueueSize ( ) , 0 ) #NEWLINE# status = self . client_communicator . RunOnce ( ) #NEWLINE# self . assertEqual ( status . code , 200 ) #NEWLINE# self . assertEqual ( self . client_communicator . client_worker . InQueueSize ( ) , 10 ) #NEWLINE# self . CheckClientQueue ( ) #NEWLINE# self . assertEqual ( len ( num_messages . messages ) , 10 )