#NEWLINE# def test_token_refresh_stream_body( self ) : #NEWLINE# #INDENT# expiration = ( datetime . datetime . utcnow ( ) + datetime . timedelta ( minutes = 15 ) ) #NEWLINE# credentials = self . _create_test_credentials ( expiration = expiration ) #NEWLINE# s = file . Storage ( FILENAME ) #NEWLINE# s . put ( credentials ) #NEWLINE# credentials = s . get ( ) #NEWLINE# new_cred = copy . copy ( credentials ) #NEWLINE# new_cred . access_token = 'bar' #NEWLINE# s . put ( new_cred ) #NEWLINE# valid_access_token = '1/3w' #NEWLINE# token_response = { #NEWLINE# #INDENT# 'access_token' : valid_access_token , #NEWLINE# 'expires_in' : 3600 , #NEWLINE# #UNINDENT# } #NEWLINE# http = HttpMockSequence ( [ ( { #NEWLINE# #INDENT# 'status' : str ( http_client . UNAUTHORIZED ) , #NEWLINE# #UNINDENT# } , b'Initial token expired' ) , ( { #NEWLINE# #INDENT# 'status' : str ( http_client . UNAUTHORIZED ) , #NEWLINE# #UNINDENT# } , b'Store token expired' ) , ( { #NEWLINE# #INDENT# 'status' : str ( http_client . OK ) , #NEWLINE# #UNINDENT# } , json . dumps ( token_response ) . encode ( 'utf-8' ) ) , ( { #NEWLINE# #INDENT# 'status' : str ( http_client . OK ) , #NEWLINE# #UNINDENT# } , 'echo_request_body' ) ] ) #NEWLINE# body = six . StringIO ( 'streaming body' ) #NEWLINE# credentials . authorize ( http ) #NEWLINE# ( _ , content ) = http . request ( 'https://example.com' , body = valid_access_token ) #NEWLINE# self . assertEqual ( content , 'streaming body' ) #NEWLINE# self . assertEqual ( credentials . access_token , valid_access_token )