#NEWLINE# @ mock . patch ( 'spotify.Link' , spec = spotify . Link ) #NEWLINE# def test_create_from_uri( self , link_mock , lib_mock ) : #NEWLINE# #INDENT# sp_track = spotify . ffi . cast ( 'sp_track *' , 42 ) #NEWLINE# link_instance_mock = link_mock . return_value #NEWLINE# link_instance_mock . as_track . return_value = spotify . Track ( self . session , sp_track = sp_track ) #NEWLINE# uri = 'spotify:track:foo' #NEWLINE# result = spotify . Track ( self . session , uri = uri ) #NEWLINE# link_mock . assert_called_with ( self . session , uri = uri ) #NEWLINE# link_instance_mock . as_track . assert_called_with ( ) #NEWLINE# lib_mock . sp_track_add_ref . assert_called_with ( sp_track ) #NEWLINE# self . assertEqual ( result . _sp_track , sp_track )