mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
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:
parent
cb430b4b4b
commit
a6066278aa
@ -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
|
|
||||||
@ -3,46 +3,42 @@
|
|||||||
Functional, browser based tests for config app.
|
Functional, browser based tests for config app.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pytest_bdd import given, parsers, scenarios, then, when
|
import pytest
|
||||||
|
|
||||||
from plinth.tests import functional
|
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}'))
|
@pytest.fixture(scope='module', autouse=True)
|
||||||
def set_home_page(session_browser, app_name):
|
def fixture_background(session_browser):
|
||||||
_set_home_page(session_browser, app_name)
|
"""Login."""
|
||||||
|
functional.login(session_browser)
|
||||||
|
|
||||||
|
|
||||||
@when(parsers.parse('I change the hostname to {hostname:w}'))
|
def test_change_hostname(session_browser):
|
||||||
def change_hostname_to(session_browser, hostname):
|
"""Test changing the hostname."""
|
||||||
_set_hostname(session_browser, hostname)
|
_set_hostname(session_browser, 'mybox')
|
||||||
|
assert _get_hostname(session_browser) == 'mybox'
|
||||||
|
|
||||||
|
|
||||||
@when(parsers.parse('I change the domain name to {domain:S}'))
|
def test_change_domain_name(session_browser):
|
||||||
def change_domain_name_to(session_browser, domain):
|
"""Test changing the domain name."""
|
||||||
functional.set_domain_name(session_browser, domain)
|
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 test_change_home_page(session_browser):
|
||||||
def change_home_page_to(session_browser, app_name):
|
"""Test changing webserver home page."""
|
||||||
_set_home_page(session_browser, app_name)
|
functional.install(session_browser, 'syncthing')
|
||||||
|
functional.app_enable(session_browser, 'syncthing')
|
||||||
|
_set_home_page(session_browser, 'syncthing')
|
||||||
|
|
||||||
|
_set_home_page(session_browser, 'plinth')
|
||||||
@then(parsers.parse('the hostname should be {hostname:w}'))
|
assert _check_home_page_redirect(session_browser, 'plinth')
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
def _get_hostname(browser):
|
def _get_hostname(browser):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user