tests: functional: Re-organize step definitions and helper methods

- Move non-reusable app specific step definitions and helper methods into
<app>/tests/test_functional.py.

- Merge reusable helper methods into plinth.tests.functional

- Merge reusable step definitions into plinth.tests.functional.step_definitions

- avahi, datetime, ikiwiki: Reuse common methods to avoid repetition. Avoid
mapping from app nicknames to actual app names.

- deluge, transmission: Make a copy of sample.torrent for each app to avoid
clogging common place.

- Implement functional.visit() to simplify a lot of browser.visit() calls.

- Ensure that name of the mark on functional tests for an app is same as name of
the app. This will help with predicting the mark when running tests for a
particular app.

Tests performed:

- Run all functional tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
Sunil Mohan Adapa authored and Joseph Nuthalapati committed 2020-05-22 22:52:40 +05:30
1 parent 8fac6a71fe
commit 80dff7bf9c
53 files changed
+3340 -3410

No files matched your search

+1 -2
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
@system @essential @configuration
@system @essential @config
Feature: Configuration
Configure the system.
@@ -21,4 +21,3 @@ Scenario: Change webserver home page
And the home page is syncthing
When I change the home page to plinth
Then the home page should be plinth
+70 -1
View File
@@ -3,6 +3,75 @@
Functional, browser based tests for config app.
"""
from pytest_bdd import scenarios
from pytest_bdd import given, parsers, scenarios, then, when
from plinth.tests import functional
scenarios('config.feature')
@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)
@when(parsers.parse('I change the hostname to {hostname:w}'))
def change_hostname_to(session_browser, hostname):
_set_hostname(session_browser, hostname)
@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)
@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)
@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)
def _get_hostname(browser):
functional.nav_to_module(browser, 'config')
return browser.find_by_id('id_hostname').value
def _set_hostname(browser, hostname):
functional.nav_to_module(browser, 'config')
browser.find_by_id('id_hostname').fill(hostname)
functional.submit(browser)
def _get_domain_name(browser):
functional.nav_to_module(browser, 'config')
return browser.find_by_id('id_domainname').value
def _set_home_page(browser, home_page):
if 'plinth' not in home_page and 'apache' not in home_page:
home_page = 'shortcut-' + home_page
functional.nav_to_module(browser, 'config')
drop_down = browser.find_by_id('id_homepage')
drop_down.select(home_page)
functional.submit(browser)
def _check_home_page_redirect(browser, app_name):
functional.visit(browser, '/')
return browser.find_by_xpath(
"//a[contains(@href, '/plinth/') and @title='FreedomBox']")