#NEWLINE# @ patch ( 'time.sleep' ) #NEWLINE# def test_rate_limited_twice( self , time_sleep ) : #NEWLINE# #INDENT# res = [ ( 429 , { #NEWLINE# #INDENT# 'Retry-After' : '10' , #NEWLINE# #UNINDENT# } , '{}' ) , ( 429 , { #NEWLINE# #INDENT# 'Retry-After' : '1' , #NEWLINE# #UNINDENT# } , '{}' ) , ( 200 , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , json . dumps ( { #NEWLINE# #INDENT# 'data' : 'me' , #NEWLINE# #UNINDENT# } ) ) ] #NEWLINE# responses . add_callback ( responses . GET , 'http://app/users/me' , callback = ( lambda r : res . pop ( 0 ) ) , content_type = 'application/json' ) #NEWLINE# self . assertEqual ( self . client . users . me ( ) , 'me' ) #NEWLINE# self . assertEqual ( len ( responses . calls ) , 3 ) #NEWLINE# self . assertEqual ( time_sleep . mock_calls , [ call ( 10.0 ) , call ( 1.0 ) ] )