From 95a3784f02b5511412102703bfc5f564fcdc9916 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Mon, 4 Oct 2021 20:18:56 -0400 Subject: [PATCH] ttrss: Convert functional tests to non-BDD python format Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- plinth/modules/ttrss/tests/test_functional.py | 40 ++++++++++++++----- plinth/modules/ttrss/tests/ttrss.feature | 29 -------------- 2 files changed, 29 insertions(+), 40 deletions(-) delete mode 100644 plinth/modules/ttrss/tests/ttrss.feature diff --git a/plinth/modules/ttrss/tests/test_functional.py b/plinth/modules/ttrss/tests/test_functional.py index c67d99f52..57e87f1f8 100644 --- a/plinth/modules/ttrss/tests/test_functional.py +++ b/plinth/modules/ttrss/tests/test_functional.py @@ -3,25 +3,43 @@ Functional, browser based tests for ttrss app. """ -from pytest_bdd import given, scenarios, then, when - +import pytest from plinth.tests import functional -scenarios('ttrss.feature') +pytestmark = [pytest.mark.apps, pytest.mark.ttrss, pytest.mark.sso] -@given('I subscribe to a feed in ttrss') -def ttrss_subscribe(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, 'ttrss') + yield + functional.app_disable(session_browser, 'ttrss') + + +def test_enable_disable(session_browser): + """Test enabling the app.""" + functional.app_disable(session_browser, 'ttrss') + + functional.app_enable(session_browser, 'ttrss') + assert functional.service_is_running(session_browser, 'ttrss') + + functional.app_disable(session_browser, 'ttrss') + assert functional.service_is_not_running(session_browser, 'ttrss') + + +@pytest.mark.backups +def test_backup_restore(session_browser): + """Test backup and restore of app data.""" + functional.app_enable(session_browser, 'ttrss') _subscribe(session_browser) + functional.backup_create(session_browser, 'ttrss', 'test_ttrss') - -@when('I unsubscribe from the feed in ttrss') -def ttrss_unsubscribe(session_browser): _unsubscribe(session_browser) + functional.backup_restore(session_browser, 'ttrss', 'test_ttrss') - -@then('I should be subscribed to the feed in ttrss') -def ttrss_assert_subscribed(session_browser): + assert functional.service_is_running(session_browser, 'ttrss') assert _is_subscribed(session_browser) diff --git a/plinth/modules/ttrss/tests/ttrss.feature b/plinth/modules/ttrss/tests/ttrss.feature deleted file mode 100644 index b1efdfa80..000000000 --- a/plinth/modules/ttrss/tests/ttrss.feature +++ /dev/null @@ -1,29 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later - -@apps @ttrss @sso -Feature: TT-RSS News Feed Reader - Run TT-RSS News Feed Reader. - -Background: - Given I'm a logged in user - Given the ttrss application is installed - -Scenario: Enable ttrss application - Given the ttrss application is disabled - When I enable the ttrss application - Then the ttrss service should be running - -@backups -Scenario: Backup and restore ttrss - Given the ttrss application is enabled - And I subscribe to a feed in ttrss - When I create a backup of the ttrss app data with name test_ttrss - And I unsubscribe from the feed in ttrss - And I restore the ttrss app data backup with name test_ttrss - Then the ttrss service should be running - And I should be subscribed to the feed in ttrss - -Scenario: Disable ttrss application - Given the ttrss application is enabled - When I disable the ttrss application - Then the ttrss service should not be running