#NEWLINE# def test_write( self ) : #NEWLINE# #INDENT# '\n            Test writing a default setting\n        ' #NEWLINE# expected = { #NEWLINE# #INDENT# 'changes' : { #NEWLINE# #INDENT# 'written' : 'com.apple.CrashReporter DialogType is set to Server' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : '' , #NEWLINE# 'name' : 'DialogType' , #NEWLINE# 'result' : True , #NEWLINE# #UNINDENT# } #NEWLINE# read_mock = MagicMock ( return_value = 'Local' ) #NEWLINE# write_mock = MagicMock ( return_value = { #NEWLINE# #INDENT# 'retcode' : 0 , #NEWLINE# #UNINDENT# } ) #NEWLINE# with patch . dict ( macdefaults . __salt__ , { #NEWLINE# #INDENT# 'macdefaults.read' : read_mock , #NEWLINE# 'macdefaults.write' : expected , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# out = macdefaults . write ( 'DialogType' , 'com.apple.CrashReporter' , 'Server' ) #NEWLINE# read_mock . assert_called_once_with ( 'com.apple.CrashReporter' , 'DialogType' , None ) #NEWLINE# write_mock . assert_called_once_with ( 'com.apple.CrashReporter' , 'DialogType' , 'Server' , 'string' , None ) #NEWLINE# self . assertEqual ( out , expected )