forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged develop into gallery_jobs7; fixed minor merge conflicts.
- Loading branch information
Showing
184 changed files
with
13,251 additions
and
4,146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,6 @@ | |
import feconf | ||
|
||
|
||
ADMIN_EMAIL = '[email protected]' | ||
BOTH_MODERATOR_AND_ADMIN_EMAIL = '[email protected]' | ||
MODERATOR_EMAIL = '[email protected]' | ||
SITE_NAME = 'sitename.org' | ||
|
||
|
||
|
@@ -34,7 +31,7 @@ class AdminIntegrationTest(test_utils.GenericTestBase): | |
def test_admin_page(self): | ||
"""Test that the admin page shows the expected sections.""" | ||
# Login as an admin. | ||
self.login('[email protected]', is_super_admin=True) | ||
self.login(self.EDITOR_EMAIL, is_super_admin=True) | ||
|
||
response = self.testapp.get('/admin') | ||
|
||
|
@@ -55,25 +52,23 @@ def test_admin_page_rights(self): | |
self.assertEqual(response.status_int, 302) | ||
|
||
# Login as a non-admin. | ||
self.login('[email protected]') | ||
self.login(self.EDITOR_EMAIL) | ||
response = self.testapp.get('/admin', expect_errors=True) | ||
self.assertEqual(response.status_int, 401) | ||
self.logout() | ||
|
||
# Login as an admin. | ||
self.login('[email protected]', is_super_admin=True) | ||
self.login(self.ADMIN_EMAIL, is_super_admin=True) | ||
response = self.testapp.get('/admin') | ||
self.assertEqual(response.status_int, 200) | ||
self.logout() | ||
|
||
def test_change_configuration_property(self): | ||
"""Test that configuration properties can be changed.""" | ||
|
||
# Login as an admin. | ||
self.login('[email protected]', is_super_admin=True) | ||
|
||
ANNOUNCEMENT_TEXT = 'TEST ANNOUNCEMENT' | ||
ANNOUNCEMENT_TEXT = self.UNICODE_TEST_STRING | ||
|
||
self.login(self.ADMIN_EMAIL, is_super_admin=True) | ||
response = self.testapp.get('/admin') | ||
csrf_token = self.get_csrf_token_from_response(response) | ||
|
||
|
@@ -106,9 +101,7 @@ def test_change_splash_page_config_property(self): | |
self.assertIn('SITE_NAME', response.body) | ||
self.assertNotIn(SITE_NAME, response.body) | ||
|
||
# Log in as an admin and customize the site name. | ||
self.login('[email protected]', is_super_admin=True) | ||
|
||
self.login(self.ADMIN_EMAIL, is_super_admin=True) | ||
response = self.testapp.get('/admin') | ||
csrf_token = self.get_csrf_token_from_response(response) | ||
self.post_json('/adminhandler', { | ||
|
@@ -117,7 +110,6 @@ def test_change_splash_page_config_property(self): | |
pages.SITE_NAME.name: SITE_NAME | ||
} | ||
}, csrf_token) | ||
|
||
self.logout() | ||
|
||
# Navigate to the splash page. The site name is set. | ||
|
@@ -129,43 +121,45 @@ def test_change_rights(self): | |
"""Test that the correct role indicators show up on app pages.""" | ||
|
||
# Navigate to any page. The role is not set. | ||
response = self.testapp.get('/') | ||
response.mustcontain(no=['Moderator', 'Admin']) | ||
self.testapp.get('/').mustcontain( | ||
no=['(Moderator)', '(Admin)', '/moderator', '/admin']) | ||
|
||
# Log in as a superadmin. The role is set. | ||
# Log in as a superadmin. This gives access to /admin. | ||
self.login('[email protected]', is_super_admin=True) | ||
response = self.testapp.get('/') | ||
response.mustcontain('Admin', no=['Moderator']) | ||
self.testapp.get('/').mustcontain( | ||
'/admin', no=['(Moderator)', '(Admin)', '/moderator']) | ||
|
||
# Add a moderator, an admin, and a person with both roles, then log | ||
# out. | ||
BOTH_MODERATOR_AND_ADMIN_EMAIL = '[email protected]' | ||
response = self.testapp.get('/admin') | ||
csrf_token = self.get_csrf_token_from_response(response) | ||
self.post_json('/adminhandler', { | ||
'action': 'save_config_properties', | ||
'new_config_property_values': { | ||
config_domain.ADMIN_EMAILS.name: [ | ||
ADMIN_EMAIL, BOTH_MODERATOR_AND_ADMIN_EMAIL], | ||
self.ADMIN_EMAIL, BOTH_MODERATOR_AND_ADMIN_EMAIL], | ||
config_domain.MODERATOR_EMAILS.name: [ | ||
MODERATOR_EMAIL, BOTH_MODERATOR_AND_ADMIN_EMAIL], | ||
self.MODERATOR_EMAIL, BOTH_MODERATOR_AND_ADMIN_EMAIL], | ||
} | ||
}, csrf_token) | ||
self.logout() | ||
|
||
# Log in as a moderator. | ||
self.login(MODERATOR_EMAIL) | ||
response = self.testapp.get(feconf.GALLERY_URL) | ||
response.mustcontain('Moderator', no=['Admin']) | ||
self.login(self.MODERATOR_EMAIL) | ||
self.testapp.get(feconf.GALLERY_URL).mustcontain( | ||
'(Moderator)', '/moderator', no=['(Admin)', '/admin']) | ||
self.logout() | ||
|
||
# Log in as an admin. | ||
self.login(ADMIN_EMAIL) | ||
response = self.testapp.get(feconf.GALLERY_URL) | ||
response.mustcontain('Admin', no=['Moderator']) | ||
self.login(self.ADMIN_EMAIL) | ||
self.testapp.get(feconf.GALLERY_URL).mustcontain( | ||
'(Admin)', '/moderator', no=['(Moderator)', '/admin']) | ||
self.logout() | ||
|
||
# Log in as a both-moderator-and-admin. | ||
# Log in as a both-moderator-and-admin. Only '(Admin)' is shown in the | ||
# navbar. | ||
self.login(BOTH_MODERATOR_AND_ADMIN_EMAIL) | ||
response = self.testapp.get(feconf.GALLERY_URL) | ||
response.mustcontain('Admin', no=['Moderator']) | ||
self.testapp.get(feconf.GALLERY_URL).mustcontain( | ||
'(Admin)', '/moderator', no=['(Moderator)', '/admin']) | ||
self.logout() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.