searx: Convert functional tests to non-BDD python format

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2021-10-02 14:49:36 -04:00 committed by Sunil Mohan Adapa
parent 60236376c2
commit 6aecad7259
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
3 changed files with 65 additions and 67 deletions

View File

@ -1,50 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
@apps @searx @sso
Feature: Searx Web Search
Run Searx metasearch engine.
Background:
Given I'm a logged in user
Given the searx application is installed
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
Given the searx application is enabled
When I create a backup of the searx app data with name test_searx
And I restore the searx app data backup with name test_searx
Then the searx site should be available
Scenario: Enable public access
Given the searx application is enabled
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
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 public access is enabled in searx
When I disable the searx application
And I enable the searx application
And I log out
Then searx app should be visible on the front page
And the searx site should be available
Scenario: Disable searx application
Given the searx application is enabled
When I disable the searx application
Then the searx site should not be available

View File

@ -3,32 +3,75 @@
Functional, browser based tests for searx app.
"""
from pytest_bdd import given, scenarios, then, when
import pytest
from plinth.tests import functional
scenarios('searx.feature')
pytestmark = [pytest.mark.apps, pytest.mark.searx]
@given('public access is enabled in searx')
def searx_public_access_enabled(session_browser):
_enable_public_access(session_browser)
@pytest.fixture(scope='module', autouse=True)
def fixture_background(session_browser):
"""Login and install the app."""
functional.login(session_browser)
functional.install(session_browser, 'searx')
yield
functional.login(session_browser)
functional.app_disable(session_browser, 'searx')
@when('I enable public access in searx')
def searx_enable_public_access(session_browser):
_enable_public_access(session_browser)
def test_enable_disable(session_browser):
"""Test enabling the app."""
functional.app_disable(session_browser, 'searx')
@when('I disable public access in searx')
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):
functional.app_enable(session_browser, 'searx')
assert functional.is_available(session_browser, 'searx')
_is_search_form_visible(session_browser)
functional.app_disable(session_browser, 'searx')
assert not functional.is_available(session_browser, 'searx')
@pytest.mark.backups
def test_backup_restore(session_browser):
"""Test backup and restore."""
functional.app_enable(session_browser, 'searx')
functional.backup_create(session_browser, 'searx', 'test_searx')
functional.backup_restore(session_browser, 'searx', 'test_searx')
assert functional.is_available(session_browser, 'searx')
def test_public_access(session_browser):
"""Test enabling public access."""
functional.app_enable(session_browser, 'searx')
# Enable public access
_enable_public_access(session_browser)
functional.logout(session_browser)
assert functional.is_visible_on_front_page(session_browser, 'searx')
assert functional.is_available(session_browser, 'searx')
# Disable public access
functional.login(session_browser)
_disable_public_access(session_browser)
functional.logout(session_browser)
assert not functional.is_visible_on_front_page(session_browser, 'searx')
assert not functional.is_available(session_browser, 'searx')
def test_preserve_public_access_setting(session_browser):
"""Test that public access setting is preserved when disabling and
re-enabling the app."""
functional.login(session_browser)
functional.app_enable(session_browser, 'searx')
_enable_public_access(session_browser)
functional.app_disable(session_browser, 'searx')
functional.app_enable(session_browser, 'searx')
functional.logout(session_browser)
assert functional.is_visible_on_front_page(session_browser, 'searx')
assert functional.is_available(session_browser, 'searx')
def _enable_public_access(browser):
"""Enable Public Access in SearX"""

View File

@ -419,6 +419,11 @@ def find_on_front_page(browser, app_name):
return shortcuts
def is_visible_on_front_page(browser, app_name):
shortcuts = find_on_front_page(browser, app_name)
return len(shortcuts) == 1
####################
# Daemon utilities #
####################