From 60236376c27f1e05900db3af498a02c70637ca7e Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Thu, 30 Sep 2021 17:14:27 -0400 Subject: [PATCH] roundcube: Convert functional tests to non-BDD python format Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- .../modules/roundcube/tests/roundcube.feature | 26 -------------- .../roundcube/tests/test_functional.py | 34 +++++++++++++++++-- 2 files changed, 32 insertions(+), 28 deletions(-) delete mode 100644 plinth/modules/roundcube/tests/roundcube.feature diff --git a/plinth/modules/roundcube/tests/roundcube.feature b/plinth/modules/roundcube/tests/roundcube.feature deleted file mode 100644 index 0baa92055..000000000 --- a/plinth/modules/roundcube/tests/roundcube.feature +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later - -@apps @roundcube -Feature: Roundcube Email Client - Run webmail client. - -Background: - Given I'm a logged in user - Given the roundcube application is installed - -Scenario: Enable roundcube application - Given the roundcube application is disabled - When I enable the roundcube application - Then the roundcube site should be available - -@backups -Scenario: Backup and restore roundcube - Given the roundcube application is enabled - When I create a backup of the roundcube app data with name test_roundcube - And I restore the roundcube app data backup with name test_roundcube - Then the roundcube site should be available - -Scenario: Disable roundcube application - Given the roundcube application is enabled - When I disable the roundcube application - Then the roundcube site should not be available diff --git a/plinth/modules/roundcube/tests/test_functional.py b/plinth/modules/roundcube/tests/test_functional.py index 0aaee4b5e..e88220190 100644 --- a/plinth/modules/roundcube/tests/test_functional.py +++ b/plinth/modules/roundcube/tests/test_functional.py @@ -3,6 +3,36 @@ Functional, browser based tests for roundcube app. """ -from pytest_bdd import scenarios +import pytest +from plinth.tests import functional -scenarios('roundcube.feature') +pytestmark = [pytest.mark.apps, pytest.mark.roundcube] + + +@pytest.fixture(scope='module', autouse=True) +def fixture_background(session_browser): + """Login and install the app.""" + functional.login(session_browser) + functional.install(session_browser, 'roundcube') + yield + functional.app_disable(session_browser, 'roundcube') + + +def test_enable_disable(session_browser): + """Test enabling the app.""" + functional.app_disable(session_browser, 'roundcube') + + functional.app_enable(session_browser, 'roundcube') + assert functional.is_available(session_browser, 'roundcube') + + functional.app_disable(session_browser, 'roundcube') + assert not functional.is_available(session_browser, 'roundcube') + + +@pytest.mark.backups +def test_backup_restore(session_browser): + """Test backup and restore.""" + functional.app_enable(session_browser, 'roundcube') + functional.backup_create(session_browser, 'roundcube', 'test_roundcube') + functional.backup_restore(session_browser, 'roundcube', 'test_roundcube') + assert functional.is_available(session_browser, 'roundcube')