#NEWLINE# def test_get_error( ) : #NEWLINE# #INDENT# td = api . API ( 'APIKEY' ) #NEWLINE# with mock . patch ( 'time.sleep' ) as t_sleep : #NEWLINE# #INDENT# td . http . request = mock . MagicMock ( ) #NEWLINE# responses = [ make_raw_response ( 404 , b'not found' ) ] #NEWLINE# td . http . request . side_effect = responses #NEWLINE# with td . get ( '/foo' , { #NEWLINE# #INDENT# 'bar' : 'baz' , #NEWLINE# #UNINDENT# } ) as response : #NEWLINE# #INDENT# ( args , kwargs ) = td . http . request . call_args #NEWLINE# assert ( args == ( 'GET' , 'https://api.treasuredata.com/foo' ) ) #NEWLINE# assert ( kwargs [ 'fields' ] == { #NEWLINE# #INDENT# 'bar' : 'baz' , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert ( sorted ( kwargs [ 'headers' ] . keys ( ) ) == [ 'accept-encoding' , 'authorization' , 'date' , 'user-agent' ] ) #NEWLINE# ( status , body ) = ( response . status , response . read ( ) ) #NEWLINE# assert ( status == 404 ) #NEWLINE# assert ( body == b'not found' ) #NEWLINE# #UNINDENT# assert ( not t_sleep . called )