diff --git a/plinth/modules/datetime/tests/datetime.feature b/plinth/modules/datetime/tests/datetime.feature deleted file mode 100644 index 718e51992..000000000 --- a/plinth/modules/datetime/tests/datetime.feature +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later - -@essential @datetime @system -Feature: Date and Time - Configure time zone and network time service. - -Background: - Given I'm a logged in user - -Scenario: Disable network time application - Given the datetime application can be disabled - And the datetime application is enabled - When I disable the datetime application - Then the datetime service should not be running - -Scenario: Enable network time application - Given the datetime application can be disabled - And the datetime application is disabled - When I enable the datetime application - Then the datetime service should be running - -Scenario: Set timezone - When I set the time zone to Africa/Abidjan - Then the time zone should be Africa/Abidjan - -@backups -Scenario: Backup and restore datetime - When I set the time zone to Africa/Accra - And I create a backup of the datetime app data with name test_datetime - And I set the time zone to Africa/Cairo - And I restore the datetime app data backup with name test_datetime - Then the time zone should be Africa/Accra diff --git a/plinth/modules/datetime/tests/test_functional.py b/plinth/modules/datetime/tests/test_functional.py index 8d4921f88..9aefa784a 100644 --- a/plinth/modules/datetime/tests/test_functional.py +++ b/plinth/modules/datetime/tests/test_functional.py @@ -3,21 +3,49 @@ Functional, browser based tests for datetime app. """ -from pytest_bdd import parsers, scenarios, then, when - +import pytest from plinth.tests import functional -scenarios('datetime.feature') +pytestmark = [pytest.mark.system, pytest.mark.essential, pytest.mark.datetime] -@when(parsers.parse('I set the time zone to {time_zone:S}')) -def time_zone_set(session_browser, time_zone): - _time_zone_set(session_browser, time_zone) +@pytest.fixture(scope='module', autouse=True) +def fixture_background(session_browser): + """Login.""" + functional.login(session_browser) -@then(parsers.parse('the time zone should be {time_zone:S}')) -def time_zone_assert(session_browser, time_zone): - assert time_zone == _time_zone_get(session_browser) +def test_enable_disable(session_browser): + """Test enabling the app.""" + if functional.app_can_be_disabled(session_browser, 'datetime'): + functional.app_disable(session_browser, 'datetime') + + functional.app_enable(session_browser, 'datetime') + assert functional.service_is_running(session_browser, 'datetime') + + functional.app_disable(session_browser, 'datetime') + assert functional.service_is_not_running(session_browser, 'datetime') + + else: + pytest.skip('datetime cannot be disabled.') + + +def test_set_timezone(session_browser): + """Test setting the timezone.""" + _time_zone_set(session_browser, 'Africa/Abidjan') + assert _time_zone_get(session_browser) == 'Africa/Abidjan' + + +@pytest.mark.backups +def test_backup_and_restore(session_browser): + """Test backup and restore of datetime settings.""" + _time_zone_set(session_browser, 'Africa/Accra') + functional.backup_create(session_browser, 'datetime', 'test_datetime') + + _time_zone_set(session_browser, 'Africa/Cairo') + functional.backup_restore(session_browser, 'datetime', 'test_datetime') + + assert _time_zone_get(session_browser) == 'Africa/Accra' def _time_zone_set(browser, time_zone):