#NEWLINE# @ mock . patch ( 'spotify.playlist.lib' , spec = spotify . lib ) #NEWLINE# def test_playlists( self , playlist_lib_mock , lib_mock ) : #NEWLINE# #INDENT# lib_mock . sp_search_error . return_value = spotify . ErrorType . OK #NEWLINE# lib_mock . sp_search_num_playlists . return_value = 1 #NEWLINE# lib_mock . sp_search_playlist_name . return_value = spotify . ffi . new ( 'char[]' , b'The Party List' ) #NEWLINE# lib_mock . sp_search_playlist_uri . return_value = spotify . ffi . new ( 'char[]' , b'spotify:playlist:foo' ) #NEWLINE# lib_mock . sp_search_playlist_image_uri . return_value = spotify . ffi . new ( 'char[]' , b'spotify:image:foo' ) #NEWLINE# sp_search = spotify . ffi . cast ( 'sp_search *' , 42 ) #NEWLINE# search = spotify . Search ( self . session , sp_search = sp_search ) #NEWLINE# self . assertEqual ( lib_mock . sp_search_add_ref . call_count , 1 ) #NEWLINE# result = search . playlists #NEWLINE# self . assertEqual ( lib_mock . sp_search_add_ref . call_count , 2 ) #NEWLINE# self . assertEqual ( len ( result ) , 1 ) #NEWLINE# lib_mock . sp_search_num_playlists . assert_called_with ( sp_search ) #NEWLINE# item = result [ 0 ] #NEWLINE# self . assertIsInstance ( item , spotify . SearchPlaylist ) #NEWLINE# self . assertEqual ( item . name , 'The Party List' ) #NEWLINE# self . assertEqual ( item . uri , 'spotify:playlist:foo' ) #NEWLINE# self . assertEqual ( item . image_uri , 'spotify:image:foo' ) #NEWLINE# self . assertEqual ( lib_mock . sp_search_playlist_name . call_count , 1 ) #NEWLINE# lib_mock . sp_search_playlist_name . assert_called_with ( sp_search , 0 ) #NEWLINE# self . assertEqual ( lib_mock . sp_search_playlist_uri . call_count , 1 ) #NEWLINE# lib_mock . sp_search_playlist_uri . assert_called_with ( sp_search , 0 ) #NEWLINE# self . assertEqual ( lib_mock . sp_search_playlist_image_uri . call_count , 1 ) #NEWLINE# lib_mock . sp_search_playlist_image_uri . assert_called_with ( sp_search , 0 )