#NEWLINE# @ mock . patch . object ( fakelibvirt . virConnect , 'secretLookupByUsage' ) #NEWLINE# def test_find_secret( self , mock_sec ) : #NEWLINE# #INDENT# 'finding secrets with various usage_type.' #NEWLINE# expected = [ mock . call ( fakelibvirt . VIR_SECRET_USAGE_TYPE_CEPH , 'rbdvol' ) , mock . call ( fakelibvirt . VIR_SECRET_USAGE_TYPE_CEPH , 'cephvol' ) , mock . call ( fakelibvirt . VIR_SECRET_USAGE_TYPE_ISCSI , 'iscsivol' ) , mock . call ( fakelibvirt . VIR_SECRET_USAGE_TYPE_VOLUME , 'vol' ) ] #NEWLINE# self . host . find_secret ( 'rbd' , 'rbdvol' ) #NEWLINE# self . host . find_secret ( 'ceph' , 'cephvol' ) #NEWLINE# self . host . find_secret ( 'iscsi' , 'iscsivol' ) #NEWLINE# self . host . find_secret ( 'volume' , 'vol' ) #NEWLINE# self . assertEqual ( expected , self . mock_calls ) #NEWLINE# self . assertRaises ( exception . NovaException , self . host . find_secret , 'foo' , 'foovol' ) #NEWLINE# mock_sec . side_effect = fakelibvirt . libvirtError ( '' ) #NEWLINE# mock_sec . side_effect . err = ( 66 , ) #NEWLINE# self . assertIsNone ( self . host . find_secret ( 'rbd' , 'rbdvol' ) )