From c92c95e39d310412f290189e5b331945f667d7e1 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Mon, 4 Oct 2021 20:36:48 -0400 Subject: [PATCH] upgrades: Convert functional tests to non-BDD python format Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- .../modules/upgrades/tests/test_functional.py | 41 ++++++++++++------- .../modules/upgrades/tests/upgrades.feature | 26 ------------ 2 files changed, 26 insertions(+), 41 deletions(-) delete mode 100644 plinth/modules/upgrades/tests/upgrades.feature diff --git a/plinth/modules/upgrades/tests/test_functional.py b/plinth/modules/upgrades/tests/test_functional.py index 48e2c60fd..22fb94106 100644 --- a/plinth/modules/upgrades/tests/test_functional.py +++ b/plinth/modules/upgrades/tests/test_functional.py @@ -3,29 +3,40 @@ Functional, browser based tests for upgrades app. """ -from pytest_bdd import given, parsers, scenarios, then, when - +import pytest from plinth.tests import functional -scenarios('upgrades.feature') +pytestmark = [pytest.mark.system, pytest.mark.essential, pytest.mark.upgrades] -@given(parsers.parse('automatic upgrades are {enabled:w}')) -def upgrades_given_enable_automatic(session_browser, enabled): - should_enable = (enabled == 'enabled') - _enable_automatic(session_browser, should_enable) +@pytest.fixture(scope='module', autouse=True) +def fixture_background(session_browser): + """Login.""" + functional.login(session_browser) + yield + _enable_automatic(session_browser, False) -@when(parsers.parse('I {enable:w} automatic upgrades')) -def upgrades_enable_automatic(session_browser, enable): - should_enable = (enable == 'enable') - _enable_automatic(session_browser, should_enable) +def test_enable_automatic_upgrades(session_browser): + """Test enabling automatic upgrades.""" + _enable_automatic(session_browser, False) + _enable_automatic(session_browser, True) + assert _get_automatic(session_browser) + + _enable_automatic(session_browser, False) + assert not _get_automatic(session_browser) -@then(parsers.parse('automatic upgrades should be {enabled:w}')) -def upgrades_assert_automatic(session_browser, enabled): - should_be_enabled = (enabled == 'enabled') - assert _get_automatic(session_browser) == should_be_enabled +@pytest.mark.backups +def test_backup_restore(session_browser): + """Test backup and restore of configuration.""" + _enable_automatic(session_browser, True) + functional.backup_create(session_browser, 'upgrades', 'test_upgrades') + + _enable_automatic(session_browser, False) + functional.backup_restore(session_browser, 'upgrades', 'test_upgrades') + + assert _get_automatic(session_browser) def _enable_automatic(browser, should_enable): diff --git a/plinth/modules/upgrades/tests/upgrades.feature b/plinth/modules/upgrades/tests/upgrades.feature deleted file mode 100644 index e828c7afc..000000000 --- a/plinth/modules/upgrades/tests/upgrades.feature +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later - -@essential @upgrades @system -Feature: Software Upgrades - Configure automatic software upgrades - -Background: - Given I'm a logged in user - -Scenario: Enable automatic upgrades - Given automatic upgrades are disabled - When I enable automatic upgrades - Then automatic upgrades should be enabled - -@backups -Scenario: Backup and restore upgrades - When I enable automatic upgrades - And I create a backup of the upgrades app data with name test_upgrades - And I disable automatic upgrades - And I restore the upgrades app data backup with name test_upgrades - Then automatic upgrades should be enabled - -Scenario: Disable automatic upgrades - Given automatic upgrades are enabled - When I disable automatic upgrades - Then automatic upgrades should be disabled