#NEWLINE# def test_uninstalled_cert( self ) : #NEWLINE# #INDENT# "\n            Test uninstalling a certificate into the OSX keychain when it's not installed\n        " #NEWLINE# expected = { #NEWLINE# #INDENT# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : 'Friendly Name already uninstalled.' , #NEWLINE# 'name' : '/path/to/cert.p12' , #NEWLINE# 'result' : True , #NEWLINE# #UNINDENT# } #NEWLINE# list_mock = MagicMock ( return_value = [ 'Cert2' ] ) #NEWLINE# friendly_mock = MagicMock ( return_value = 'Friendly Name' ) #NEWLINE# uninstall_mock = MagicMock ( return_value = '1 identity imported.' ) #NEWLINE# with patch . dict ( keychain . __salt__ , { #NEWLINE# #INDENT# 'keychain.list_certs' : list_mock , #NEWLINE# 'keychain.get_friendly_name' : friendly_mock , #NEWLINE# 'keychain.uninstall' : friendly_mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# out = keychain . uninstalled ( '/path/to/cert.p12' , 'passw0rd' ) #NEWLINE# list_mock . assert_called_once_with ( '/Library/Keychains/System.keychain' ) #NEWLINE# friendly_mock . assert_called_once_with ( '/path/to/cert.p12' , 'passw0rd' ) #NEWLINE# assert ( not uninstall_mock . called ) #NEWLINE# self . assertEqual ( out , expected )