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:
Sunil Mohan Adapa authored and James Valleroy committed 2021-08-25 08:19:57 -04:00
1 parent 28030933dc
commit 5340cf3119
3 files changed
+13 -9

No files matched your search

+10 -6
View File
@@ -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]
+2 -2
View File
@@ -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'))