config: 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-20 19:52:49 -04:00 committed by Sunil Mohan Adapa
parent cb430b4b4b
commit a6066278aa
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 25 additions and 56 deletions

View File

@ -1,27 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
@system @essential @config
Feature: Configuration
Configure the system.
Background:
Given I'm a logged in user
Scenario: Change hostname
When I change the hostname to mybox
Then the hostname should be mybox
Scenario: Change domain name
When I change the domain name to mydomain.example
Then the domain name should be mydomain.example
Scenario: Capitalized domain name
When I change the domain name to Mydomain.example
Then the domain name should be mydomain.example
Scenario: Change webserver home page
Given the syncthing application is installed
And the syncthing application is enabled
And the home page is syncthing
When I change the home page to plinth
Then the home page should be plinth

View File

@ -3,46 +3,42 @@
Functional, browser based tests for config app.
"""
from pytest_bdd import given, parsers, scenarios, then, when
import pytest
from plinth.tests import functional
scenarios('config.feature')
pytestmark = [pytest.mark.system, pytest.mark.essential, pytest.mark.config]
@given(parsers.parse('the home page is {app_name:w}'))
def set_home_page(session_browser, app_name):
_set_home_page(session_browser, app_name)
@pytest.fixture(scope='module', autouse=True)
def fixture_background(session_browser):
"""Login."""
functional.login(session_browser)
@when(parsers.parse('I change the hostname to {hostname:w}'))
def change_hostname_to(session_browser, hostname):
_set_hostname(session_browser, hostname)
def test_change_hostname(session_browser):
"""Test changing the hostname."""
_set_hostname(session_browser, 'mybox')
assert _get_hostname(session_browser) == 'mybox'
@when(parsers.parse('I change the domain name to {domain:S}'))
def change_domain_name_to(session_browser, domain):
functional.set_domain_name(session_browser, domain)
def test_change_domain_name(session_browser):
"""Test changing the domain name."""
functional.set_domain_name(session_browser, 'mydomain.example')
assert _get_domain_name(session_browser) == 'mydomain.example'
# Capitalization is ignored.
functional.set_domain_name(session_browser, 'Mydomain.example')
assert _get_domain_name(session_browser) == 'mydomain.example'
@when(parsers.parse('I change the home page to {app_name:w}'))
def change_home_page_to(session_browser, app_name):
_set_home_page(session_browser, app_name)
def test_change_home_page(session_browser):
"""Test changing webserver home page."""
functional.install(session_browser, 'syncthing')
functional.app_enable(session_browser, 'syncthing')
_set_home_page(session_browser, 'syncthing')
@then(parsers.parse('the hostname should be {hostname:w}'))
def hostname_should_be(session_browser, hostname):
assert _get_hostname(session_browser) == hostname
@then(parsers.parse('the domain name should be {domain:S}'))
def domain_name_should_be(session_browser, domain):
assert _get_domain_name(session_browser) == domain
@then(parsers.parse('the home page should be {app_name:w}'))
def home_page_should_be(session_browser, app_name):
assert _check_home_page_redirect(session_browser, app_name)
_set_home_page(session_browser, 'plinth')
assert _check_home_page_redirect(session_browser, 'plinth')
def _get_hostname(browser):