datetime: Convert functional tests to non-BDD python format

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2021-09-23 14:35:25 -04:00 committed by Sunil Mohan Adapa
parent 397d6a424e
commit 0baa96f605
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 37 additions and 41 deletions

View File

@ -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

View File

@ -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):