searx: Improve functional tests

- Make tests more semantically correct
- Add implementation for missing fixture - When I log out
- Check whether file exists when disabling public access

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2019-06-07 13:32:28 +05:30 committed by James Valleroy
parent 7e1e5182cc
commit 23e4aac400
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
4 changed files with 17 additions and 9 deletions

View File

@ -181,7 +181,8 @@ def subcommand_enable_public_access(_):
def subcommand_disable_public_access(_):
"""Disable public access to the SearX application."""
os.remove(PUBLIC_ACCESS_SETTING_FILE)
if os.path.exists(PUBLIC_ACCESS_SETTING_FILE):
os.remove(PUBLIC_ACCESS_SETTING_FILE)
action_utils.webserver_enable('searx-freedombox-auth')

View File

@ -41,21 +41,21 @@ Scenario: Disable searx application
Scenario: Enable public access
Given the searx application is enabled
And I enable public access in searx
And I'm a logged out user
When I enable public access in searx
And I log out
Then searx app should be visible on the front page
And the searx site should be available
Scenario: Disable public access
Given the searx application is enabled
And I disable public access in searx
And I'm a logged out user
When I disable public access in searx
And I log out
Then searx app should not be visible on the front page
And the searx site should not be available
Scenario: Preserve public access setting
Given the searx application is enabled
And I enable public access in searx
And public access is enabled in searx
When I disable the searx application
And I enable the searx application
And I log out

View File

@ -425,12 +425,17 @@ def openvpn_profile_download_compare(browser, openvpn_download_profile):
assert openvpn_download_profile == new_profile
@given('I enable public access in searx')
@given('public access is enabled in searx')
def searx_public_access_enabled(browser):
application.searx_enable_public_access(browser)
@when('I enable public access in searx')
def searx_enable_public_access(browser):
application.searx_enable_public_access(browser)
@given('I disable public access in searx')
@when('I disable public access in searx')
def searx_disable_public_access(browser):
application.searx_disable_public_access(browser)

View File

@ -29,12 +29,14 @@ def logged_in_user(browser):
config['DEFAULT']['password'])
@when("I log out")
@given("I'm a logged out user")
def logged_out_user(browser):
browser.visit(default_url + '/plinth/accounts/logout/')
log_out = when("I log out")(logged_out_user)
@then(parsers.parse('I should be prompted for login'))
def prompted_for_login(browser):
assert interface.is_login_prompt(browser)