Custom (non-EPICS) ophyd device for the Canon CR-N300 PTZ remote camera. Phase 1 (implemented): standalone control that works with the imaging stack absent. PTZ/zoom/focus exposed as positioners (move()/set() -> status, stop(), spec limits: pan +/-170 deg, tilt -30..+100 deg, 20x zoom); camera parameters (exposure/iris, gain, white balance, focus mode, presets) via read()/describe() with read-back verification; Manual + Continuous/Face/Tracking AF focus modes. Control plane (transport/, pure stdlib, no ophyd): - CameraTransport ABC; XCTransport implements the Canon XC Control Protocol (session open/claim/yield, HTTP/CGI) with an injectable opener; FakeTransport is a full in-memory simulator for offline mode and tests. Spec-defined CGI paths/params/axis encodings (BPE-7216-005) are isolated and flagged for hardware verification. Imaging plane (acquisition/, pure stdlib, no ophyd, not a control dependency): - FrameRingBuffer (bounded, thread-safe, stores compressed frames) and a persistent, fail-soft, instrumented StreamWorker. Phase-2 grab API (get_latest/get_latest_n/get_nearest, decode-on-grab) seamed in the device. Credentials come from env vars (CANON_<NAME>_USER/_PASSWORD), never YAML/Redis. Adds example device config (real + simulation), a README, and pytest coverage (transport mocked, ring buffer, stream worker, device logic) — no hardware required. No new third-party dependencies (Phase-2 decode uses cv2, already a csaxs_bec dependency). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Getting Started with Testing using pytest
BEC is using the pytest framework. It can be installed via
pip install pytest
in your python environment.
We note that pytest is part of the optional-dependencies [dev] of the plugin package.
Introduction
Tests in this package should be stored in the tests directory.
We suggest to sort tests of different submodules, i.e. scans or devices in the respective folder structure, and to folow a naming convention of <test_module_name.py>.
It is mandatory for test files to begin with test_ for pytest to discover them.
To run all tests, navigate to the directory of the plugin from the command line, and run the command
pytest -v --random-order ./tests
Note, the python environment needs to be active.
The additional arg -v allows pytest to run in verbose mode which provides more detailed information about the tests being run.
The argument --random-order instructs pytest to run the tests in random order, which is the default in the CI pipelines.
Test examples
Writing tests can be quite specific for the given function. We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes. A very useful class to enable isolated testing is MagicMock. In addition, we also recommend to take a look at the How-to guides from pytest.