#NEWLINE# @ istest #NEWLINE# def grants_privilege_with_grant_option_if_not_granted_yet( self ) : #NEWLINE# #INDENT# with patch . object ( self . role , 'has_grant' ) as has_grant , self . execute_mock ( ) as execute : #NEWLINE# #INDENT# has_grant . return_value = False #NEWLINE# result = self . role . ensure_grant ( 'ALL PRIVILEGES' , on = 'foo' , username = 'john' , login_from = '%' , with_grant_option = True ) #NEWLINE# self . assertTrue ( result ) #NEWLINE# execute . assert_called_with ( 'mysql -u root -e "GRANT ALL PRIVILEGES ON foo.* TO \'john\'@\'%\' WITH GRANT OPTION" mysql' , stdout = False , sudo = True )