mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +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(
|
parsers.parse(
|
||||||
'I can log in as the user {username:w} with password {password:w}'))
|
'I can log in as the user {username:w} with password {password:w}'))
|
||||||
def can_log_in_with_password(session_browser, username, password):
|
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,
|
functional.login_with_account(session_browser, functional.base_url,
|
||||||
username, password)
|
username, password)
|
||||||
assert len(session_browser.find_by_id('id_user_menu')) > 0
|
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):
|
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'],
|
login_with_account(browser, base_url, config['DEFAULT']['username'],
|
||||||
config['DEFAULT']['password'])
|
config['DEFAULT']['password'])
|
||||||
|
|
||||||
|
|
||||||
def login_with_account(browser, url, username, password=None):
|
def login_with_account(browser, url, username, password=None):
|
||||||
|
"""Login to the FreedomBox interface with provided account."""
|
||||||
if password is None:
|
if password is None:
|
||||||
password = get_password(username)
|
password = get_password(username)
|
||||||
# XXX: Find a way to remove the hardcoded jsxc URL
|
# 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])
|
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 #
|
# App utilities #
|
||||||
#################
|
#################
|
||||||
@ -356,10 +361,9 @@ def _change_app_status(browser, app_name, change_status_to='enabled'):
|
|||||||
|
|
||||||
if button:
|
if button:
|
||||||
should_enable_field = browser.find_by_id('id_should_enable')
|
should_enable_field = browser.find_by_id('id_should_enable')
|
||||||
if (should_enable_field.value == 'False'
|
if (should_enable_field.value == 'False' and change_status_to
|
||||||
and change_status_to == 'disabled') or (
|
== 'disabled') or (should_enable_field.value == 'True'
|
||||||
should_enable_field.value == 'True'
|
and change_status_to == 'enabled'):
|
||||||
and change_status_to == 'enabled'):
|
|
||||||
submit(browser, element=button)
|
submit(browser, element=button)
|
||||||
else:
|
else:
|
||||||
checkbox_id = _app_checkbox_id[app_name]
|
checkbox_id = _app_checkbox_id[app_name]
|
||||||
|
|||||||
@ -18,12 +18,12 @@ def logged_in(session_browser):
|
|||||||
|
|
||||||
@given("I'm a logged out user")
|
@given("I'm a logged out user")
|
||||||
def logged_out_user(session_browser):
|
def logged_out_user(session_browser):
|
||||||
functional.visit(session_browser, '/plinth/accounts/logout/')
|
functional.logout(session_browser)
|
||||||
|
|
||||||
|
|
||||||
@when("I log out")
|
@when("I log out")
|
||||||
def log_out_user(session_browser):
|
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'))
|
@given(parsers.parse('the {app_name:w} application is installed'))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user