mediawiki: enable/disable public registrations - refactoring & tests

- Add two functional tests to test enabling and disabling public registrations
  for MediaWiki
- Refactor and simplify config-file editing logic in actions script

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
Joseph Nuthalapati committed 2018-05-07 19:41:33 +05:30
1 parent 5e2151d6b4
commit 0c334b7231
10 files changed
+121 -56

No files matched your search

+2 -1
View File
@@ -194,4 +194,5 @@ tags
# End of https://www.gitignore.io/api/vim,emacs,macos,python,vagrant
test_plinth/
geckodriver.log
geckodriver.log
.pytest_cache
@@ -32,3 +32,13 @@ Scenario: Disable mediawiki application
Given the mediawiki application is enabled
When I disable the mediawiki application
Then the mediawiki site should not be available
Scenario: Enable public registrations
Given the mediawiki application is enabled
When I enable mediawiki public registrations
Then the mediawiki site should allow creating accounts
Scenario: Disable public registrations
Given the mediawiki application is enabled
When I disable mediawiki public registrations
Then the mediawiki site should not allow creating accounts
@@ -164,3 +164,13 @@ def verify_nonexistant_share(browser, name):
@then(parsers.parse('the share {name:w} should not be accessible'))
def verify_inaccessible_share(browser, name):
application.verify_inaccessible_share(browser, name)
@when(parsers.parse('I enable mediawiki public registrations'))
def enable_mediawiki_public_registrations(browser):
application.enable_mediawiki_public_registrations(browser)
@when(parsers.parse('I disable mediawiki public registrations'))
def disable_mediawiki_public_registrations(browser):
application.disable_mediawiki_public_registrations(browser)
+10
View File
@@ -40,3 +40,13 @@ def access_application(browser, app_name):
'I should be able to login to coquelicot with password {password:w}'))
def verify_upload_password(browser, password):
site.verify_coquelicot_upload_password(browser, password)
@then(parsers.parse('the mediawiki site should allow creating accounts'))
def mediawiki_allows_creating_accounts(browser):
site.verify_mediawiki_create_account_link(browser)
@then(parsers.parse('the mediawiki site should not allow creating accounts'))
def mediawiki_does_not_allow_creating_accounts(browser):
site.verify_mediawiki_no_create_account_link(browser)
+18 -2
View File
@@ -85,9 +85,11 @@ def install(browser, app_name):
sleep(2) # XXX This shouldn't be required.
def _change_status(browser, app_name, change_status_to='enabled'):
def _change_status(browser, app_name, change_status_to='enabled',
checkbox_id=None):
interface.nav_to_module(browser, get_app_module(app_name))
checkbox = browser.find_by_id(get_app_checkbox_id(app_name))
checkbox_id = checkbox_id or get_app_checkbox_id(app_name)
checkbox = browser.find_by_id(checkbox_id)
checkbox.check() if change_status_to == 'enabled' else checkbox.uncheck()
interface.submit(browser, 'form-configuration')
if app_name in apps_with_loaders:
@@ -216,3 +218,17 @@ def verify_inaccessible_share(browser, name):
url = '{}/share/{}'.format(default_url, name)
browser.visit(url)
eventually(lambda: '/plinth' in browser.url, args=[])
def enable_mediawiki_public_registrations(browser):
"""Enable public registrations in MediaWiki."""
interface.nav_to_module(browser, 'mediawiki')
_change_status(browser, 'mediawiki', 'enabled',
checkbox_id='id_enable_public_registrations')
def disable_mediawiki_public_registrations(browser):
"""Enable public registrations in MediaWiki."""
interface.nav_to_module(browser, 'mediawiki')
_change_status(browser, 'mediawiki', 'disabled',
checkbox_id='id_enable_public_registrations')
+12
View File
@@ -57,3 +57,15 @@ def verify_coquelicot_upload_password(browser, password):
actions.perform()
assert eventually(browser.is_element_present_by_css,
args=['div[style*="display: none;"]'])
def verify_mediawiki_create_account_link(browser):
browser.visit(config['DEFAULT']['url'] + '/mediawiki')
assert eventually(browser.is_element_present_by_id,
args=['pt-createaccount'])
def verify_mediawiki_no_create_account_link(browser):
browser.visit(config['DEFAULT']['url'] + '/mediawiki')
assert eventually(browser.is_element_not_present_by_id,
args=['pt-createaccount'])