From 23e4aac400ae5e9a081a18d54713d1a30fcd763a Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Fri, 7 Jun 2019 13:32:28 +0530 Subject: [PATCH] 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 Reviewed-by: James Valleroy --- actions/searx | 3 ++- functional_tests/features/searx.feature | 10 +++++----- functional_tests/step_definitions/application.py | 9 +++++++-- functional_tests/step_definitions/interface.py | 4 +++- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/actions/searx b/actions/searx index 31bba4e31..2d9ccda4e 100755 --- a/actions/searx +++ b/actions/searx @@ -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') diff --git a/functional_tests/features/searx.feature b/functional_tests/features/searx.feature index 69d67d3cc..c8e6a185a 100644 --- a/functional_tests/features/searx.feature +++ b/functional_tests/features/searx.feature @@ -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 diff --git a/functional_tests/step_definitions/application.py b/functional_tests/step_definitions/application.py index ae1fd23ad..cd3699268 100644 --- a/functional_tests/step_definitions/application.py +++ b/functional_tests/step_definitions/application.py @@ -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) diff --git a/functional_tests/step_definitions/interface.py b/functional_tests/step_definitions/interface.py index 62a289212..b049e5535 100644 --- a/functional_tests/step_definitions/interface.py +++ b/functional_tests/step_definitions/interface.py @@ -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)