From ce231254f0ffd1e1d388e35bc8d9fbfe00fcade5 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Thu, 16 Jul 2020 08:04:29 +0530 Subject: [PATCH] searx: Add functional test for app availability Add a functional test that checks whether the SearX web application is available. This can catch the case of an Internal Server Error thrown by uWSGI server. See Debian bug https://bugs.debian.org/965095 Signed-off-by: Joseph Nuthalapati Reviewed-by: James Valleroy --- plinth/modules/searx/tests/searx.feature | 1 + plinth/modules/searx/tests/test_functional.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plinth/modules/searx/tests/searx.feature b/plinth/modules/searx/tests/searx.feature index 66b01baa4..83f0b07b7 100644 --- a/plinth/modules/searx/tests/searx.feature +++ b/plinth/modules/searx/tests/searx.feature @@ -12,6 +12,7 @@ Scenario: Enable searx application Given the searx application is disabled When I enable the searx application Then the searx site should be available + And the search form should be visible @backups Scenario: Backup and restore searx diff --git a/plinth/modules/searx/tests/test_functional.py b/plinth/modules/searx/tests/test_functional.py index e24ca2548..747067bb1 100644 --- a/plinth/modules/searx/tests/test_functional.py +++ b/plinth/modules/searx/tests/test_functional.py @@ -3,7 +3,7 @@ Functional, browser based tests for searx app. """ -from pytest_bdd import given, scenarios, when +from pytest_bdd import given, scenarios, then, when from plinth.tests import functional @@ -25,6 +25,11 @@ def searx_disable_public_access(session_browser): _disable_public_access(session_browser) +@then('the search form should be visible') +def is_searx_search_form_visible(session_browser): + _is_search_form_visible(session_browser) + + def _enable_public_access(browser): """Enable Public Access in SearX""" functional.nav_to_module(browser, 'searx') @@ -37,3 +42,10 @@ def _disable_public_access(browser): functional.nav_to_module(browser, 'searx') browser.find_by_id('id_public_access').uncheck() functional.submit(browser, form_class='form-configuration') + + +def _is_search_form_visible(browser): + """Checks whether the search box is shown in the Searx web interface.""" + searx_app_url = functional.config['DEFAULT']['url'] + '/searx' + browser.visit(searx_app_url) + assert browser.find_by_id("search_form")