#NEWLINE# def help_test_queue_rate( self , handler , throttle_rate , queue_length ) : #NEWLINE# #INDENT# handler = handler . set_throttle_rate ( throttle_rate ) #NEWLINE# handler = handler . set_queue_length ( queue_length ) #NEWLINE# self . assertIsInstance ( handler , subscribe . QueueMessageHandler ) #NEWLINE# received = { #NEWLINE# #INDENT# 'msg' : None , #NEWLINE# #UNINDENT# } #NEWLINE# def cb( msg ) : #NEWLINE# #INDENT# received [ 'msg' ] = msg #NEWLINE# #UNINDENT# handler . publish = cb #NEWLINE# throttle_rate_sec = ( throttle_rate / 1000.0 ) #NEWLINE# time . sleep ( throttle_rate_sec ) #NEWLINE# for x in range ( queue_length ) : #NEWLINE# #INDENT# handler . handle_message ( x ) #NEWLINE# #UNINDENT# time . sleep ( ( throttle_rate_sec / 2.0 ) ) #NEWLINE# try : #NEWLINE# #INDENT# for x in range ( 10 ) : #NEWLINE# #INDENT# self . assertEqual ( x , received [ 'msg' ] ) #NEWLINE# time . sleep ( throttle_rate_sec ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# handler . finish ( ) #NEWLINE# raise #NEWLINE# #UNINDENT# return handler