#NEWLINE# def test_absent( self ) : #NEWLINE# #INDENT# '\n        Test to ensure that the grant is absent.\n        ' #NEWLINE# name = 'frank_exampledb' #NEWLINE# ret = { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'result' : True , #NEWLINE# 'comment' : '' , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# mock = MagicMock ( side_effect = [ True , False ] ) #NEWLINE# mock_t = MagicMock ( side_effect = [ True , True , True , False , False ] ) #NEWLINE# mock_str = MagicMock ( return_value = 'salt' ) #NEWLINE# mock_none = MagicMock ( return_value = None ) #NEWLINE# with patch . dict ( mysql_grants . __salt__ , { #NEWLINE# #INDENT# 'mysql.grant_exists' : mock_t , #NEWLINE# 'mysql.grant_revoke' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# with patch . dict ( mysql_grants . __opts__ , { #NEWLINE# #INDENT# 'test' : True , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'MySQL grant frank_exampledb is set to be revoked' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# 'result' : None , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( mysql_grants . absent ( name ) , ret ) #NEWLINE# #UNINDENT# with patch . dict ( mysql_grants . __opts__ , { #NEWLINE# #INDENT# 'test' : False , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'Grant None on None for None@localhost has been revoked' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# 'result' : True , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# name : 'Absent' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( mysql_grants . absent ( name ) , ret ) #NEWLINE# with patch . object ( mysql_grants , '_get_mysql_error' , mock_str ) : #NEWLINE# #INDENT# comt = 'Unable to revoke grant None on None for None@localhost (salt)' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# 'result' : False , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( mysql_grants . absent ( name ) , ret ) #NEWLINE# comt = 'Unable to determine if grant None on None for None@localhost exists (salt)' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( mysql_grants . absent ( name ) , ret ) #NEWLINE# #UNINDENT# #UNINDENT# with patch . object ( mysql_grants , '_get_mysql_error' , mock_none ) : #NEWLINE# #INDENT# comt = 'Grant None on None to None@localhost is not present, so it cannot be revoked' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# 'result' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( mysql_grants . absent ( name ) , self )