From db32e885d930e65c1f369edb8ea9d4bff6d34e27 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Thu, 23 Sep 2021 22:33:56 -0400 Subject: [PATCH] dynamicdns: Convert functional tests to non-BDD python format Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- .../dynamicdns/tests/dynamicdns.feature | 28 ------------ .../dynamicdns/tests/test_functional.py | 43 +++++++++++-------- 2 files changed, 25 insertions(+), 46 deletions(-) delete mode 100644 plinth/modules/dynamicdns/tests/dynamicdns.feature diff --git a/plinth/modules/dynamicdns/tests/dynamicdns.feature b/plinth/modules/dynamicdns/tests/dynamicdns.feature deleted file mode 100644 index 707850544..000000000 --- a/plinth/modules/dynamicdns/tests/dynamicdns.feature +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later - -# TODO Scenario: Configure GnuDIP service -# TODO Scenario: Configure noip.com service -# TODO Scenario: Configure selfhost.bz service -# TODO Scenario: Configure freedns.afraid.org service -# TODO Scenario: Configure other update URL service - -@apps @dynamicdns -Feature: Dynamic DNS Client - Update public IP to a GnuDIP server. - -Background: - Given I'm a logged in user - And the dynamicdns application is installed - -Scenario: Capitalized domain name - Given dynamicdns is configured - When I change the domain name to FreedomBox.example.com - Then the domain name should be freedombox.example.com - -@backups -Scenario: Backup and restore configuration - Given dynamicdns is configured - When I create a backup of the dynamicdns app data with name test_dynamicdns - And I change the dynamicdns configuration - And I restore the dynamicdns app data backup with name test_dynamicdns - Then dynamicdns should have the original configuration diff --git a/plinth/modules/dynamicdns/tests/test_functional.py b/plinth/modules/dynamicdns/tests/test_functional.py index 2aa075bc6..ceee92ea8 100644 --- a/plinth/modules/dynamicdns/tests/test_functional.py +++ b/plinth/modules/dynamicdns/tests/test_functional.py @@ -5,36 +5,43 @@ Functional, browser based tests for dynamicdns app. import time -from pytest_bdd import given, parsers, scenarios, then, when - +import pytest from plinth.tests import functional -scenarios('dynamicdns.feature') +pytestmark = [ + pytest.mark.system, pytest.mark.essential, pytest.mark.dynamicdns +] -@given('dynamicdns is configured') -def dynamicdns_configure(session_browser): +@pytest.fixture(scope='module', autouse=True) +def fixture_background(session_browser): + """Login.""" + functional.login(session_browser) + + +def test_capitalized_domain_name(session_browser): + """Test handling of capitalized domain name.""" _configure(session_browser) + _configure_domain(session_browser, 'FreedomBox.example.com') + assert _get_domain(session_browser) == 'freedombox.example.com' -@when('I change the dynamicdns configuration') -def dynamicdns_change_config(session_browser): +def test_backup_and_restore(session_browser): + """Test backup and restore of configuration.""" + _configure(session_browser) + functional.backup_create(session_browser, 'dynamicdns', 'test_dynamicdns') + _change_config(session_browser) + functional.backup_restore(session_browser, 'dynamicdns', 'test_dynamicdns') - -@when(parsers.parse('I change the domain name to {domain:S}')) -def dynamicdns_change_domain(session_browser, domain): - _configure_domain(session_browser, domain) - - -@then('dynamicdns should have the original configuration') -def dynamicdns_has_original_config(session_browser): assert _has_original_config(session_browser) -@then(parsers.parse('the domain name should be {domain:S}')) -def dynamicdns_has_domain(session_browser, domain): - assert _get_domain(session_browser) == domain +# TODO Scenario: Configure GnuDIP service +# TODO Scenario: Configure noip.com service +# TODO Scenario: Configure selfhost.bz service +# TODO Scenario: Configure freedns.afraid.org service +# TODO Scenario: Configure other update URL service def _configure(browser):