tests: functional: Merge into main source hierarchy

- Add pytest hooks to ignore all functional tests if pytest_bdd is not
installed.

- Update pytest hooks to skip tests in file named 'test_functional.py' if
--include-functional argument is not provided.

- Move functional_tests/install.py into plinth/tests/functional and update
reference in Vagrantfile.

- Move scenario files into individual app folders. Rename them after the app
they are testing. Merge TODO items listed in todo.org into corresponding feature
files.

- Add test_functional.py in each app to build tests from the features file using
pytest_bdd.

- Move all step_definitions, support and data into plinth/tests/functional/.
Include all step_definitions from conftest.py. Update to relative imports
instead of absolute imports.

Tests performed:

- Run py.test-3 --collect-only shows all functional tests and lists 574 tests.
No errors show that name of feature files are correct. The number says that all
functional test features are included.

- Remove pytest_bdd (or modify the import name) and run py.test-3 --collect-only
skips collecting all functional tests and shows only 300+ tests.

- Run functional tests for a few apps with py.test-3 --include-functional -m
app. For storage, deluge.

- Run unit tests with py.test-3. Functional tests are listed by skipped.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
Sunil Mohan Adapa 2020-05-19 13:11:23 -07:00 committed by Joseph Nuthalapati
parent 1bf3a27174
commit 80d67c2054
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35
122 changed files with 444 additions and 73 deletions

2
Vagrantfile vendored
View File

@ -38,7 +38,7 @@ Vagrant.configure(2) do |config|
DEBIAN_FRONTEND=noninteractive apt-get install -y ncurses-term DEBIAN_FRONTEND=noninteractive apt-get install -y ncurses-term
echo 'alias run-develop="sudo -u plinth /vagrant/run --develop"' >> /home/vagrant/.bashrc echo 'alias run-develop="sudo -u plinth /vagrant/run --develop"' >> /home/vagrant/.bashrc
SHELL SHELL
config.vm.provision "tests", run: "never", type: "shell", path: "functional_tests/install.sh" config.vm.provision "tests", run: "never", type: "shell", path: "plinth/tests/functional/install.sh"
config.vm.post_up_message = "FreedomBox virtual machine is ready config.vm.post_up_message = "FreedomBox virtual machine is ready
for development. You can run the development version of Plinth using for development. You can run the development version of Plinth using
the following command. the following command.

View File

@ -3,11 +3,30 @@
pytest configuration for all tests. pytest configuration for all tests.
""" """
import importlib
import os import os
import pathlib import pathlib
import pytest import pytest
try:
importlib.import_module('pytest_bdd')
_bdd_available = True
except ImportError:
_bdd_available = False
else:
from plinth.tests.functional.step_definitions.application import *
from plinth.tests.functional.step_definitions.interface import *
from plinth.tests.functional.step_definitions.service import *
from plinth.tests.functional.step_definitions.site import *
from plinth.tests.functional.step_definitions.system import *
def pytest_ignore_collect(path, config):
"""Return True to ignore functional tests."""
if path.basename == 'test_functional.py':
return not _bdd_available
def pytest_addoption(parser): def pytest_addoption(parser):
"""Add a command line option to run functional tests.""" """Add a command line option to run functional tests."""
@ -16,7 +35,7 @@ def pytest_addoption(parser):
def pytest_collection_modifyitems(config, items): def pytest_collection_modifyitems(config, items):
"""Filter out functional tests unless --include-functional arg is passed.""" """Filter out functional tests unless --include-functional is passed."""
if config.getoption('--include-functional'): if config.getoption('--include-functional'):
# Option provided on command line, no filtering # Option provided on command line, no filtering
return return
@ -24,7 +43,9 @@ def pytest_collection_modifyitems(config, items):
skip_functional = pytest.mark.skip( skip_functional = pytest.mark.skip(
reason='--include-functional not provided') reason='--include-functional not provided')
for item in items: for item in items:
if 'functional' in item.keywords: if 'functional' in item.keywords or (
item.parent.fspath.basename
and item.parent.fspath.basename == 'test_functional.py'):
item.add_marker(skip_functional) item.add_marker(skip_functional)

View File

@ -1,19 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
import pytest
try:
from pytest_bdd import scenarios
except ImportError:
pytestmark = pytest.mark.skip(reason='pytest_bdd is not installed')
else:
from step_definitions.application import *
from step_definitions.interface import *
from step_definitions.service import *
from step_definitions.site import *
from step_definitions.system import *
# Mark all tests are functional
pytestmark = pytest.mark.functional
scenarios('features')

View File

@ -1,35 +0,0 @@
* Feature: Users and Groups
** TODO Scenario: Add user to wiki group
** TODO Scenario: Remove user from wiki group
** TODO Scenario: Set user SSH key
** TODO Scenario: Clear user SSH key
** TODO Scenario: Make user inactive
** TODO Scenario: Make user active
** TODO Scenario: Change user password
* Feature: Help
** TODO Scenario: Visit the wiki
** TODO Scenario: Visit the mailing list
** TODO Scenario: Visit the IRC channel
** TODO Scenario: View the manual
** TODO Scenario: View the about page
* Feature: Bookmarks
** TODO Enable/Disable
* Feature: Chat Server
** TODO Check service
** TODO Check domain name display
* Feature: Dynamic DNS Client
** TODO Scenario: Configure GnuDIP service
** TODO Scenario: Configure noip.com service
** TODO Scenario: Configure selfhost.bz service
** TODO Scenario: Configure freedns.afraid.org service
** TODO Scenario: Configure other update URL service
* Feature: Public Visibility
** TODO Scenario: Enable standard services
** TODO Scenario: Disable standard services
** TODO Scenario: Add custom service
** TODO Scenario: Delete custom service

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for avahi app.
"""
from pytest_bdd import scenarios
scenarios('avahi.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for backups app.
"""
from pytest_bdd import scenarios
scenarios('backups.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for bind app.
"""
from pytest_bdd import scenarios
scenarios('bind.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for cockpit app.
"""
from pytest_bdd import scenarios
scenarios('cockpit.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for config app.
"""
from pytest_bdd import scenarios
scenarios('config.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for coquelicot app.
"""
from pytest_bdd import scenarios
scenarios('coquelicot.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for coturn app.
"""
from pytest_bdd import scenarios
scenarios('coturn.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for datetime app.
"""
from pytest_bdd import scenarios
scenarios('datetime.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for deluge app.
"""
from pytest_bdd import scenarios
scenarios('deluge.feature')

View File

@ -1,5 +1,11 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
# TODO Scenario: Configure GnuDIP service
# TODO Scenario: Configure noip.com service
# TODO Scenario: Configure selfhost.bz service
# TODO Scenario: Configure freedns.afraid.org service
# TODO Scenario: Configure other update URL service
@apps @dynamicdns @apps @dynamicdns
Feature: Dynamic DNS Client Feature: Dynamic DNS Client
Update public IP to a GnuDIP server. Update public IP to a GnuDIP server.

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for dynamicdns app.
"""
from pytest_bdd import scenarios
scenarios('dynamicdns.feature')

View File

@ -1,5 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
# TODO Check service
# TODO Check domain name display
@apps @ejabberd @apps @ejabberd
Feature: Ejabberd Chat Server Feature: Ejabberd Chat Server
Run ejabberd chat server. Run ejabberd chat server.

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for ejabberd app.
"""
from pytest_bdd import scenarios
scenarios('ejabberd.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for gitweb app.
"""
from pytest_bdd import scenarios
scenarios('gitweb.feature')

View File

@ -1,5 +1,11 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
# TODO Scenario: Visit the wiki
# TODO Scenario: Visit the mailing list
# TODO Scenario: Visit the IRC channel
# TODO Scenario: View the manual
# TODO Scenario: View the about page
@help @system @essential @help @system @essential
Feature: Help module Feature: Help module
Show various information about the system. Show various information about the system.

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for help app.
"""
from pytest_bdd import scenarios
scenarios('help.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for i2p app.
"""
from pytest_bdd import scenarios
scenarios('i2p.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for ikiwiki app.
"""
from pytest_bdd import scenarios
scenarios('ikiwiki.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for infinoted app.
"""
from pytest_bdd import scenarios
scenarios('infinoted.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for jsxc app.
"""
from pytest_bdd import scenarios
scenarios('jsxc.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for matrixsynapse app.
"""
from pytest_bdd import scenarios
scenarios('matrixsynapse.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for mediawiki app.
"""
from pytest_bdd import scenarios
scenarios('mediawiki.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for minetest app.
"""
from pytest_bdd import scenarios
scenarios('minetest.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for minidlna app.
"""
from pytest_bdd import scenarios
scenarios('minidlna.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for mldonkey app.
"""
from pytest_bdd import scenarios
scenarios('mldonkey.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for monkeysphere app.
"""
from pytest_bdd import scenarios
scenarios('monkeysphere.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for mumble app.
"""
from pytest_bdd import scenarios
scenarios('mumble.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for openvpn app.
"""
from pytest_bdd import scenarios
scenarios('openvpn.feature')

View File

@ -1,5 +1,10 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
# TODO Scenario: Enable standard services
# TODO Scenario: Disable standard services
# TODO Scenario: Add custom service
# TODO Scenario: Delete custom service
@apps @pagekite @apps @pagekite
Feature: Pagekite Public Visibility Feature: Pagekite Public Visibility
Configure Pagekite public visitbility server. Configure Pagekite public visitbility server.

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for pagekite app.
"""
from pytest_bdd import scenarios
scenarios('pagekite.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for performance app.
"""
from pytest_bdd import scenarios
scenarios('performance.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for privoxy app.
"""
from pytest_bdd import scenarios
scenarios('privoxy.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for quassel app.
"""
from pytest_bdd import scenarios
scenarios('quassel.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for radicale app.
"""
from pytest_bdd import scenarios
scenarios('radicale.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for roundcube app.
"""
from pytest_bdd import scenarios
scenarios('roundcube.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for samba app.
"""
from pytest_bdd import scenarios
scenarios('samba.feature')

View File

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for searx app.
"""
from pytest_bdd import scenarios
scenarios('searx.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for security app.
"""
from pytest_bdd import scenarios
scenarios('security.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for shadowsocks app.
"""
from pytest_bdd import scenarios
scenarios('shadowsocks.feature')

View File

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for sharing app.
"""
from pytest_bdd import scenarios
scenarios('sharing.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for snapshot app.
"""
from pytest_bdd import scenarios
scenarios('snapshot.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for ssh app.
"""
from pytest_bdd import scenarios
scenarios('ssh.feature')

View File

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for sso app.
"""
from pytest_bdd import scenarios
scenarios('sso.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for storage app.
"""
from pytest_bdd import scenarios
scenarios('storage.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for syncthing app.
"""
from pytest_bdd import scenarios
scenarios('syncthing.feature')

View File

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for tahoe app.
"""
from pytest_bdd import scenarios
scenarios('tahoe.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for tor app.
"""
from pytest_bdd import scenarios
scenarios('tor.feature')

View File

@ -0,0 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for transmission app.
"""
from pytest_bdd import scenarios
scenarios('transmission.feature')

Some files were not shown because too many files have changed in this diff Show More