Skip to content

Test suite and ruff#18

Merged
JeanLucPons merged 5 commits into
mainfrom
17-add-a-real-test-suite-for-pyaml-cs-oa
Apr 30, 2026
Merged

Test suite and ruff#18
JeanLucPons merged 5 commits into
mainfrom
17-add-a-real-test-suite-for-pyaml-cs-oa

Conversation

@gupichon
Copy link
Copy Markdown
Contributor

@gupichon gupichon commented Apr 29, 2026

Summary

Add a first real pytest suite for pyaml-cs-oa, focused on fast mocked tests that do not require live EPICS/Tango infrastructure.

This PR also converts the existing tune scripts into proper pytest integration tests, adds a GitHub Actions workflow for linting and testing, and aligns the local Ruff configuration with PyAML.

Closes #17

Changes

  • Add pytest configuration in pyproject.toml, including:
    • test = ["pytest"] optional dependency group.
    • python_files = ["test_*.py"] so pytest does not collect non-standard script names unexpectedly.
    • integration and requires_control_system markers.
  • Align Ruff configuration with PyAML:
    • line-length = 127.
    • Ignore E741 and B024, matching the PyAML configuration.
  • Apply Ruff import sorting and formatting to the repository so the new GitHub Actions workflow can pass.
  • Add shared test fakes for ophyd-like signal/backend/status behavior.
  • Add unit coverage for:
    • OAReadback and OASetpoint.
    • EPICS and Tango get_SP_RB() factories.
    • OASignal build and metadata behavior.
    • OphydAsyncControlSystem.attach() prefixing and caching behavior.
    • OAScalarAggregator validation, get, set, and readback behavior.
    • Indexed BPM orbit aggregation, including the case where one shared orbit vector is read once for all BPMs.
  • Convert tests/test-tune.py and tests/test-tune-bessy.py into standard pytest files:
    • tests/test_tune.py
    • tests/test_tune_bessy.py
    • tests/live_tune_helpers.py
  • Mark live tune tests as integration and requires_control_system, skipped by default unless PYAML_CS_OA_RUN_INTEGRATION=1 is set.
  • Add .github/workflows/tests.yml to install dependencies, run Ruff, and run pytest.

Validation

Local default test run:

38 passed, 2 skipped, 1 warning

Commands used locally:

python -m ruff check .
python -m pytest -q

The 2 skipped tests are the live integration tests, which require control-system infrastructure.

Also checked:

git diff --check

Notes

  • The remaining warning is an existing ophyd-async deprecation warning from pyaml_cs_oa/epics.py:
Use `ophyd_async.epics.core` instead of `ophyd_async.epics.signal`
  • The live tune tests can be run explicitly with:
$env:PYAML_CS_OA_RUN_INTEGRATION='1'
python -m pytest tests/test_tune.py tests/test_tune_bessy.py
  • The Ruff changes are intentionally part of this PR because .github/workflows/tests.yml runs Ruff. Without aligning the configuration here, the GitHub workflow would fail independently of the test-suite changes.

@gupichon gupichon requested a review from JeanLucPons April 29, 2026 14:44
@gupichon gupichon self-assigned this Apr 29, 2026
@gupichon gupichon linked an issue Apr 29, 2026 that may be closed by this pull request
@gupichon gupichon changed the title Test suite Test suite and ruff Apr 29, 2026
@gupichon
Copy link
Copy Markdown
Contributor Author

@JeanLucPons, could you check this? Modifications to existing files are limited to ruff formatting. All other changes consist of new tests.

@JeanLucPons
Copy link
Copy Markdown
Contributor

The tests need the BESSY VA ?
How it works with github runner ?

@JeanLucPons
Copy link
Copy Markdown
Contributor

Would it be possible to add this tests after the refurbishment ?
Lots of things will change and we will have to redo the tests ?

@gupichon
Copy link
Copy Markdown
Contributor Author

I actually intend to use them for the refurbishment. I've added a test for the BPMs you mentioned. It would have caught the issues you were referring to.

@gupichon
Copy link
Copy Markdown
Contributor Author

The tests need the BESSY VA ? How it works with github runner ?

A VA isn't necessary here. It follows the same logic as tango-pyaml, using mocking and fake interfaces for simulation. As you can see, it works fine on the GitHub runner.

@JeanLucPons JeanLucPons merged commit 44070ba into main Apr 30, 2026
1 check passed
@JeanLucPons JeanLucPons deleted the 17-add-a-real-test-suite-for-pyaml-cs-oa branch April 30, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a real test suite for pyaml-cs-oa

4 participants