#NEWLINE# def test_permissions( self ) : #NEWLINE# #INDENT# self . assertEqual ( 302 , self . client . post ( reverse ( 'admin:experiment_admin_set_state' ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . status_code ) #NEWLINE# self . assertEqual ( 302 , self . client . post ( reverse ( 'admin:experiment_admin_set_alternative' ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . status_code ) #NEWLINE# response = self . client . post ( reverse ( 'admin:experiment_admin_set_alternative' ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( response . status_code , 302 ) #NEWLINE# user = User . objects . create_user ( username = 'user' , password = 'pass' ) #NEWLINE# user . save ( ) #NEWLINE# self . client . login ( username = 'user' , password = 'pass' ) #NEWLINE# self . assertEqual ( 302 , self . client . post ( reverse ( 'admin:experiment_admin_set_state' ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . status_code ) #NEWLINE# self . assertEqual ( 302 , self . client . post ( reverse ( 'admin:experiment_admin_set_alternative' ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . status_code ) #NEWLINE# user . is_staff = True #NEWLINE# user . save ( ) #NEWLINE# self . assertEqual ( 403 , self . client . post ( reverse ( 'admin:experiment_admin_set_state' ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . status_code ) #NEWLINE# self . assertEqual ( 403 , self . client . post ( reverse ( 'admin:experiment_admin_set_alternative' ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . status_code ) #NEWLINE# permission = Permission . objects . get ( codename = 'change_experiment' ) #NEWLINE# user . user_permissions . add ( permission ) #NEWLINE# self . assertEqual ( 400 , self . client . post ( reverse ( 'admin:experiment_admin_set_state' ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . status_code ) #NEWLINE# self . assertEqual ( 400 , self . client . post ( reverse ( 'admin:experiment_admin_set_alternative' ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . status_code )