From 93e9f95d1876ffea8187929767aa592b3e157e55 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Thu, 30 Sep 2021 11:02:42 -0400 Subject: [PATCH] privoxy: Convert functional tests to non-BDD python format Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- plinth/modules/privoxy/tests/privoxy.feature | 26 --------------- .../modules/privoxy/tests/test_functional.py | 33 +++++++++++++++++-- 2 files changed, 31 insertions(+), 28 deletions(-) delete mode 100644 plinth/modules/privoxy/tests/privoxy.feature diff --git a/plinth/modules/privoxy/tests/privoxy.feature b/plinth/modules/privoxy/tests/privoxy.feature deleted file mode 100644 index ff397339d..000000000 --- a/plinth/modules/privoxy/tests/privoxy.feature +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later - -@apps @privoxy -Feature: Privoxy Web Proxy - Proxy web connections for enhanced privacy. - -Background: - Given I'm a logged in user - Given the privoxy application is installed - -Scenario: Enable privoxy application - Given the privoxy application is disabled - When I enable the privoxy application - Then the privoxy service should be running - -@backups -Scenario: Backup and restore privoxy - Given the privoxy application is enabled - When I create a backup of the privoxy app data with name test_privoxy - And I restore the privoxy app data backup with name test_privoxy - Then the privoxy service should be running - -Scenario: Disable privoxy application - Given the privoxy application is enabled - When I disable the privoxy application - Then the privoxy service should not be running diff --git a/plinth/modules/privoxy/tests/test_functional.py b/plinth/modules/privoxy/tests/test_functional.py index 10638de5d..3554532d8 100644 --- a/plinth/modules/privoxy/tests/test_functional.py +++ b/plinth/modules/privoxy/tests/test_functional.py @@ -3,6 +3,35 @@ Functional, browser based tests for privoxy app. """ -from pytest_bdd import scenarios +import pytest +from plinth.tests import functional -scenarios('privoxy.feature') +pytestmark = [pytest.mark.apps, pytest.mark.privoxy] + + +@pytest.fixture(scope='module', autouse=True) +def fixture_background(session_browser): + """Login and install the app.""" + functional.login(session_browser) + functional.install(session_browser, 'privoxy') + yield + functional.app_disable(session_browser, 'privoxy') + + +def test_enable_disable(session_browser): + """Test enabling the app.""" + functional.app_disable(session_browser, 'privoxy') + + functional.app_enable(session_browser, 'privoxy') + assert functional.service_is_running(session_browser, 'privoxy') + + functional.app_disable(session_browser, 'privoxy') + assert functional.service_is_not_running(session_browser, 'privoxy') + + +def test_backup_restore(session_browser): + """Test backup and restore.""" + functional.app_enable(session_browser, 'privoxy') + functional.backup_create(session_browser, 'privoxy', 'test_privoxy') + functional.backup_restore(session_browser, 'privoxy', 'test_privoxy') + assert functional.service_is_running(session_browser, 'privoxy')