#NEWLINE# @ istest #NEWLINE# def creates_a_user_if_it_doesnt_exist_yet( self ) : #NEWLINE# #INDENT# with patch . object ( execute . role , 'user_exists' ) as user_exists , self . execute_mock ( ) as execute : #NEWLINE# #INDENT# user_exists . return_value = False #NEWLINE# result = self . role . ensure_user ( 'johndoe' , 'mypass' , 'localhost' ) #NEWLINE# self . assertTrue ( result ) #NEWLINE# execute . assert_called_with ( 'mysql -u root -e "CREATE USER \'johndoe\'@\'localhost\' IDENTIFIED BY \'mypass\';" mysql' , sudo = True , stdout = False )