#NEWLINE# @ patch ( 'ramses.auth.transaction' ) #NEWLINE# @ patch ( 'ramses.auth.cryptacular' ) #NEWLINE# def test_create_system_user_created( self , mock_crypt , mock_trans ) : #NEWLINE# #INDENT# from ramses import auth #NEWLINE# encoder = mock_crypt . bcrypt . BCRYPTPasswordManager ( ) #NEWLINE# encoder . encode . return_value = '654321' #NEWLINE# config = Mock ( ) #NEWLINE# config . registry . settings = { #NEWLINE# #INDENT# 'system.user' : 'user12' , #NEWLINE# 'system.password' : '123456' , #NEWLINE# 'system.email' : 'user12@example.com' , #NEWLINE# #UNINDENT# } #NEWLINE# config . registry . auth_model . get_or_create . return_value = ( Mock ( ) , True ) #NEWLINE# auth . create_system_user ( config ) #NEWLINE# mock_trans . commit . assert_called_once_with ( ) #NEWLINE# encoder . encode . assert_called_once_with ( '123456' ) #NEWLINE# config . registry . auth_model . get_or_create . assert_called_once_with ( username = 'user12' , defaults = { #NEWLINE# #INDENT# 'password' : '654321' , #NEWLINE# 'email' : 'user12@example.com' , #NEWLINE# 'groups' : [ 'admin' ] , #NEWLINE# '_acl' : [ ( Allow , 'g:admin' , ALL_PERMISSIONS ) ] , #NEWLINE# #UNINDENT# } )