Skip to content

13. Testing and development ​

The repository layout and how to run the tests.

Repository layout ​

text
elabftw-toolkit/
├── pyproject.toml
├── README.md
├── README_en.md
├── LICENSE
├── .env.example
├── mkdocs.yml               # settings for building docs/ as a site (optional)
├── docs/                    # user guide (ja / en)
├── src/
│   └── elabftw_toolkit/
│       ├── __init__.py
│       ├── client.py        # client() and elab.experiments / elab.items / entry(id)
│       ├── teams.py
│       ├── categories.py
│       ├── statuses.py
│       ├── templates.py
│       ├── experiments.py
│       ├── items.py
│       ├── search.py
│       ├── metadata_utils.py
│       ├── fields.py        # entry.fields, extra_fields(), etc.
│       ├── links.py
│       ├── tags.py
│       ├── html_tables.py
│       ├── files.py
│       ├── images.py
│       ├── steps.py
│       ├── permissions.py
│       ├── common.py
│       ├── dataframe.py
│       ├── maiml.py
│       └── _http.py         # API calls bypassing the SDK (timeout, GET retries)
└── tests/
    ├── test_client.py       # offline unit tests (pytest)
    ├── test_utils.py        # offline unit tests (pytest)
    ├── test_maiml.py        # offline unit tests (pytest)
    └── live/                # scripts that write to a real server (not collected by pytest)
        ├── test_init.py
        ├── test_id.py
        ├── test_exp_*.py
        ├── test_item_*.py
        ├── test_usergroups.py
        ├── test_allowed_tags.csv
        ├── .env.test.example
        ├── test_file/
        └── output/

Offline unit tests ​

tests/test_*.py are unit tests that do not connect to eLabFTW (the API is replaced with unittest.mock). Running pytest at the repository root collects only these.

bash
python -m pip install -e ".[maiml]" pytest
pytest

tests/test_maiml.py is skipped when pymaiml is not installed.

fake (FakeELN) in tests/conftest.py is a stand-in ELN that keeps entries as dicts; the schema, plan, duplicate, change-record and link-field tests (test_schema.py, test_plan.py, test_find.py) use it. tests/test_compat.py checks with dir() that the installed elabapi_python has every API class and method the toolkit uses (run it first after upgrading elabapi_python).

Scripts for checking against a real server (tests/live/) ​

tests/live/ contains scripts that check each feature against a real eLabFTW server. pytest does not collect them (--ignore=tests/live in pyproject.toml). Every script changes its working directory to tests/live/, so put .env.test, test_file/, output/, and test_allowed_tags.csv in that folder (copy .env.test.example to start).

bash
python tests/live/test_init.py
python tests/live/test_id.py

python tests/live/test_exp_init.py
python tests/live/test_exp_search.py
python tests/live/test_exp_metadata.py
python tests/live/test_exp_structured_metadata.py
python tests/live/test_exp_field_link.py
python tests/live/test_exp_link.py
python tests/live/test_exp_category_status.py
python tests/live/test_exp_tags.py
python tests/live/test_exp_html.py
python tests/live/test_exp_files_upload.py
python tests/live/test_exp_files_download.py
python tests/live/test_exp_image.py
python tests/live/test_exp_download.py
python tests/live/test_exp_lock.py
python tests/live/test_exp_steps.py
python tests/live/test_exp_permissions.py
python tests/live/test_exp_templates.py

python tests/live/test_item_init.py
python tests/live/test_item_search.py
python tests/live/test_item_metadata.py
python tests/live/test_item_structured_metadata.py
python tests/live/test_item_field_link.py
python tests/live/test_item_link.py
python tests/live/test_item_category_status.py
python tests/live/test_item_tags.py
python tests/live/test_item_html.py
python tests/live/test_item_files_upload.py
python tests/live/test_item_files_download.py
python tests/live/test_item_image.py
python tests/live/test_item_download.py
python tests/live/test_item_lock.py
python tests/live/test_item_steps.py
python tests/live/test_item_permissions.py
python tests/live/test_item_templates.py

python tests/live/test_usergroups.py

python tests/live/test_sdk_compat.py   # read-only: does the installed elabapi_python work against the real server (6.0.x)

These scripts access a real eLabFTW server and may create, update, or delete Experiments / Resource items, metadata, tags, links, attachments, body HTML, and more.

Before running them, check .env, experiment_id, item_id, template names, category names, status names, Resource item names, linked Experiment names, files to upload, and so on against your environment. Run them with a test team, templates, Experiments, and Resource items.

Documentation ​

The user guide is in docs/ja/ (Japanese) and docs/en/ (English). The index is docs/README.md. With mkdocs.yml in place, installing MkDocs lets you browse it as a site with mkdocs serve (no build tooling is included in the repository).

Apache License 2.0