#NEWLINE# def test_present( self ) : #NEWLINE# #INDENT# '\n            Test to verify that the raid is present\n        ' #NEWLINE# ret = [ { #NEWLINE# #INDENT# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : 'Raid salt already present' , #NEWLINE# 'name' : 'salt' , #NEWLINE# 'result' : True , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : "Devices are a mix of RAID constituents (['dev0']) and non-RAID-constituents(['dev1'])." , #NEWLINE# 'name' : 'salt' , #NEWLINE# 'result' : False , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : 'Raid will be created with: True' , #NEWLINE# 'name' : 'salt' , #NEWLINE# 'result' : None , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : 'Raid salt failed to be created.' , #NEWLINE# 'name' : 'salt' , #NEWLINE# 'result' : False , #NEWLINE# #UNINDENT# } ] #NEWLINE# mock = MagicMock ( side_effect = [ { #NEWLINE# #INDENT# 'salt' : True , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'salt' : False , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'salt' : False , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'salt' : False , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'salt' : False , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# with patch . dict ( mdadm . __salt__ , { #NEWLINE# #INDENT# 'raid.list' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertEqual ( mdadm . present ( 'salt' , 5 , 'dev0' ) , ret [ 0 ] ) #NEWLINE# mock = MagicMock ( side_effect = [ 0 , 1 ] ) #NEWLINE# with patch . dict ( mdadm . __salt__ , { #NEWLINE# #INDENT# 'cmd.retcode' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertDictEqual ( mdadm . present ( 'salt' , 5 , [ 'dev0' , 'dev1' ] ) , ret [ 1 ] ) #NEWLINE# #UNINDENT# mock = MagicMock ( return_value = True ) #NEWLINE# with patch . dict ( mdadm . __salt__ , { #NEWLINE# #INDENT# 'cmd.retcode' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# with patch . dict ( mdadm . __opts__ , { #NEWLINE# #INDENT# 'test' : True , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# with patch . dict ( mdadm . __salt__ , { #NEWLINE# #INDENT# 'raid.create' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertDictEqual ( mdadm . present ( 'salt' , 5 , 'dev0' ) , ret [ 2 ] ) #NEWLINE# #UNINDENT# #UNINDENT# with patch . dict ( mdadm . __opts__ , { #NEWLINE# #INDENT# 'test' : False , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# with patch . dict ( mdadm . __salt__ , { #NEWLINE# #INDENT# 'raid.create' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertDictEqual ( mdadm . present ( 'salt' , 5 , 'dev0' ) , ret [ 3 ] )