<s> """<STR_LIT>""" <EOL> from core . controllers import editor <EOL> from core . controllers import pages <EOL> from core . domain import config_domain <EOL> from core . tests import test_utils <EOL> import feconf <EOL> BOTH_MODERATOR_AND_ADMIN_EMAIL = '<STR_LIT>' <EOL> BOTH_MODERATOR_AND_ADMIN_USERNAME = '<STR_LIT>' <EOL> SITE_FORUM_URL = '<STR_LIT>' <EOL> class AdminIntegrationTest ( test_utils . GenericTestBase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( AdminIntegrationTest , self ) . setUp ( ) <EOL> self . signup ( self . ADMIN_EMAIL , self . ADMIN_USERNAME ) <EOL> self . signup ( self . EDITOR_EMAIL , self . EDITOR_USERNAME ) <EOL> def test_admin_page ( self ) : <EOL> """<STR_LIT>""" <EOL> self . login ( self . ADMIN_EMAIL , is_super_admin = True ) <EOL> response = self . testapp . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_int , <NUM_LIT:200> ) <EOL> response . mustcontain ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> self . logout ( ) <EOL> def test_admin_page_rights ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . testapp . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_int , <NUM_LIT> ) <EOL> self . login ( self . EDITOR_EMAIL ) <EOL> response = self . testapp . get ( '<STR_LIT>' , expect_errors = True ) <EOL> self . assertEqual ( response . status_int , <NUM_LIT> ) <EOL> self . logout ( ) <EOL> self . login ( self . ADMIN_EMAIL , is_super_admin = True ) <EOL> response = self . testapp . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_int , <NUM_LIT:200> ) <EOL> self . logout ( ) <EOL> def test_change_configuration_property ( self ) : <EOL> """<STR_LIT>""" <EOL> self . login ( self . ADMIN_EMAIL , is_super_admin = True ) <EOL> response = self . testapp . get ( '<STR_LIT>' ) <EOL> csrf_token = self . get_csrf_token_from_response ( response ) <EOL> response_dict = self . get_json ( '<STR_LIT>' ) <EOL> response_config_properties = response_dict [ '<STR_LIT>' ] <EOL> self . assertDictContainsSubset ( { <EOL> '<STR_LIT:value>' : editor . MODERATOR_REQUEST_FORUM_URL_DEFAULT_VALUE , <EOL> } , response_config_properties [ editor . MODERATOR_REQUEST_FORUM_URL . name ] ) <EOL> payload = { <EOL> '<STR_LIT:action>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> editor . MODERATOR_REQUEST_FORUM_URL . name : ( <EOL> self . UNICODE_TEST_STRING ) , <EOL> } <EOL> } <EOL> self . post_json ( '<STR_LIT>' , payload , csrf_token ) <EOL> response_dict = self . get_json ( '<STR_LIT>' ) <EOL> response_config_properties = response_dict [ '<STR_LIT>' ] <EOL> self . assertDictContainsSubset ( { <EOL> '<STR_LIT:value>' : self . UNICODE_TEST_STRING , <EOL> } , response_config_properties [ editor . MODERATOR_REQUEST_FORUM_URL . name ] ) <EOL> self . logout ( ) <EOL> def test_change_about_page_config_property ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . testapp . get ( '<STR_LIT>' ) <EOL> self . assertIn ( '<STR_LIT>' , response . body ) <EOL> self . assertNotIn ( SITE_FORUM_URL , response . body ) <EOL> self . login ( self . ADMIN_EMAIL , is_super_admin = True ) <EOL> response = self . testapp . get ( '<STR_LIT>' ) <EOL> csrf_token = self . get_csrf_token_from_response ( response ) <EOL> self . post_json ( '<STR_LIT>' , { <EOL> '<STR_LIT:action>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> pages . SITE_FORUM_URL . name : SITE_FORUM_URL <EOL> } <EOL> } , csrf_token ) <EOL> self . logout ( ) <EOL> response = self . testapp . get ( '<STR_LIT>' ) <EOL> self . assertNotIn ( '<STR_LIT>' , response . body ) <EOL> self . assertIn ( SITE_FORUM_URL , response . body ) <EOL> def test_change_rights ( self ) : <EOL> """<STR_LIT>""" <EOL> self . signup ( self . MODERATOR_EMAIL , self . MODERATOR_USERNAME ) <EOL> self . signup ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . signup ( <EOL> BOTH_MODERATOR_AND_ADMIN_EMAIL , BOTH_MODERATOR_AND_ADMIN_USERNAME ) <EOL> self . testapp . get ( '<STR_LIT>' ) . mustcontain ( no = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . login ( '<STR_LIT>' , is_super_admin = True ) <EOL> self . testapp . get ( '<STR_LIT>' ) . mustcontain ( '<STR_LIT>' , no = [ '<STR_LIT>' ] ) <EOL> response = self . testapp . get ( '<STR_LIT>' ) <EOL> csrf_token = self . get_csrf_token_from_response ( response ) <EOL> self . post_json ( '<STR_LIT>' , { <EOL> '<STR_LIT:action>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> config_domain . ADMIN_USERNAMES . name : [ <EOL> self . ADMIN_USERNAME , <EOL> BOTH_MODERATOR_AND_ADMIN_USERNAME ] , <EOL> config_domain . MODERATOR_USERNAMES . name : [ <EOL> self . MODERATOR_USERNAME , <EOL> BOTH_MODERATOR_AND_ADMIN_USERNAME ] , <EOL> } <EOL> } , csrf_token ) <EOL> self . logout ( ) <EOL> self . login ( self . MODERATOR_EMAIL ) <EOL> self . testapp . get ( feconf . GALLERY_URL ) . mustcontain ( <EOL> '<STR_LIT>' , no = [ '<STR_LIT>' ] ) <EOL> self . logout ( ) <EOL> self . login ( self . ADMIN_EMAIL ) <EOL> self . testapp . get ( feconf . GALLERY_URL ) . mustcontain ( <EOL> '<STR_LIT>' , no = [ '<STR_LIT>' ] ) <EOL> self . logout ( ) <EOL> self . login ( BOTH_MODERATOR_AND_ADMIN_EMAIL ) <EOL> self . assertEqual ( self . testapp . get ( '<STR_LIT:/>' ) . status_int , <NUM_LIT> ) <EOL> self . testapp . get ( feconf . GALLERY_URL ) . mustcontain ( <EOL> '<STR_LIT>' , no = [ '<STR_LIT>' ] ) <EOL> self . logout ( ) </s>
