mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
tests: functional: Add a convenience method to logout
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
28030933dc
commit
5340cf3119
@ -158,7 +158,7 @@ def can_log_in(session_browser, username):
|
||||
parsers.parse(
|
||||
'I can log in as the user {username:w} with password {password:w}'))
|
||||
def can_log_in_with_password(session_browser, username, password):
|
||||
functional.visit(session_browser, '/plinth/accounts/logout/')
|
||||
functional.logout(session_browser)
|
||||
functional.login_with_account(session_browser, functional.base_url,
|
||||
username, password)
|
||||
assert len(session_browser.find_by_id('id_user_menu')) > 0
|
||||
|
||||
@ -248,13 +248,13 @@ def _create_admin_account(browser, username, password):
|
||||
|
||||
|
||||
def login(browser):
|
||||
"""Login to the interface."""
|
||||
"""Login to the FreedomBox interface with default test account."""
|
||||
login_with_account(browser, base_url, config['DEFAULT']['username'],
|
||||
config['DEFAULT']['password'])
|
||||
|
||||
|
||||
def login_with_account(browser, url, username, password=None):
|
||||
|
||||
"""Login to the FreedomBox interface with provided account."""
|
||||
if password is None:
|
||||
password = get_password(username)
|
||||
# XXX: Find a way to remove the hardcoded jsxc URL
|
||||
@ -294,6 +294,11 @@ def login_with_account(browser, url, username, password=None):
|
||||
submit(browser, element=browser.find_by_name('next')[0])
|
||||
|
||||
|
||||
def logout(browser):
|
||||
"""Log out of the FreedomBox interface."""
|
||||
visit(browser, '/plinth/accounts/logout/')
|
||||
|
||||
|
||||
#################
|
||||
# App utilities #
|
||||
#################
|
||||
@ -356,10 +361,9 @@ def _change_app_status(browser, app_name, change_status_to='enabled'):
|
||||
|
||||
if button:
|
||||
should_enable_field = browser.find_by_id('id_should_enable')
|
||||
if (should_enable_field.value == 'False'
|
||||
and change_status_to == 'disabled') or (
|
||||
should_enable_field.value == 'True'
|
||||
and change_status_to == 'enabled'):
|
||||
if (should_enable_field.value == 'False' and change_status_to
|
||||
== 'disabled') or (should_enable_field.value == 'True'
|
||||
and change_status_to == 'enabled'):
|
||||
submit(browser, element=button)
|
||||
else:
|
||||
checkbox_id = _app_checkbox_id[app_name]
|
||||
|
||||
@ -18,12 +18,12 @@ def logged_in(session_browser):
|
||||
|
||||
@given("I'm a logged out user")
|
||||
def logged_out_user(session_browser):
|
||||
functional.visit(session_browser, '/plinth/accounts/logout/')
|
||||
functional.logout(session_browser)
|
||||
|
||||
|
||||
@when("I log out")
|
||||
def log_out_user(session_browser):
|
||||
functional.visit(session_browser, '/plinth/accounts/logout/')
|
||||
functional.logout(session_browser)
|
||||
|
||||
|
||||
@given(parsers.parse('the {app_name:w} application is installed'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user