With increasing complexity and funcionality of Layman, number of tests using Layman's REST API also grew. This led to complicated searchability as it was not clear which tests belongs to which functionality. It also led to many time consuming tests as each such test required new publication to be published, which takes about 5s per publication.
We decided to structure tests according to simple decision tree introduced below. Our goal was better searchability of current tests and also better options of optimization to decrease tests duration.
make test
make test-separated
Additional parameters for pytest command line
--nocleanup
: Do not delete publications after tests
- Every direct subfolder of
tests
, e.g.static_data
orfailed_publications
, relies on that tests from other folders will not use their workspaces. - Each test in
tests
andsrc
takes into account that other workspaces may be created in parallel. Also, in such other workspaces, publications can be created and deleted in parallel. - Tests in
tests/static_data
do not change tested data defined intests/static_data/__init__.py
(users, workspaces, publications). These tests can also share tested data among them and they are able to run in parallel with other tests intests/static_data
. - Tests in
tests/static_data/multi_publications
are testing only multi-publication endpoints. Tests intests/static_data/single_publication
are testing only single-publication endpoints.
- For each test in
tests/static_data
, ensure that at least one combination of testing data exists intests/static_data/__init__.py::PUBLICATIONS
. It should be done byassert
intests/static_data/__init__.py
.
We expect to change this decision tree over time.
- Is it test of upgrade/migration?
- YES: It belongs to
tests/upgrade
.
- YES: It belongs to
- Is the test without
ensure_layman*
fixtures and methods?- YES: It belongs to
src
.
- YES: It belongs to
- Is the test restarting Layman or running Layman with non-default environment variables?
- YES: It belongs to
tests/restart
.
- YES: It belongs to
- Is the test independent on data in Layman (e.g. users, workspaces, or publications)?
- YES: It belongs to
tests/immputable_endpoints
.
- YES: It belongs to
- Is the test testing workspaces or users?
- YES: It belongs to
tests/users_and_workspaces
.
- YES: It belongs to
- Is the test testing errors of publication endpoints, including errors in asynchronous tasks?
- YES: It belongs to
tests/failed_publications
.
- YES: It belongs to
- Is the test testing state before and after publication-related action, e.g. PATCH Layer or WFS-T, or during asynchronous task?
- YES: It belongs to
tests/dynamic_data
.
- YES: It belongs to
- Is the test testing multiple publication endpoints?
- YES: It belongs to
tests/static_data/multi_publications
.
- YES: It belongs to
- Otherwise: It belongs to
tests/static_data/single_publications
.