#NEWLINE# @ mock . patch . object ( image_service , 'get_image_service' , autospec = True ) #NEWLINE# @ mock . patch . object ( images , 'image_to_raw' , autospec = True ) #NEWLINE# @ mock . patch . object ( __builtin__ , 'open' , autospec = True ) #NEWLINE# def test_fetch_image_service_force_raw( self , open_mock , image_to_raw_mock , image_service_mock ) : #NEWLINE# #INDENT# mock_file_handle = mock . MagicMock ( spec = file ) #NEWLINE# mock_file_handle . __enter__ . return_value = 'file' #NEWLINE# open_mock . return_value = self #NEWLINE# images . fetch ( 'context' , 'image_href' , 'path' , force_raw = True ) #NEWLINE# open_mock . assert_called_once_with ( 'path' , 'wb' ) #NEWLINE# image_service_mock . return_value . download . assert_called_once_with ( 'image_href' , 'file' ) #NEWLINE# image_to_raw_mock . assert_called_once_with ( 'image_href' , 'path' , 'path.part' )