Skip to content

Add tests for pyopia.cli generate-config and modify-config - #394

Merged
animmosmith merged 9 commits into
mainfrom
142-cli-tests
Aug 5, 2026
Merged

Add tests for pyopia.cli generate-config and modify-config#394
animmosmith merged 9 commits into
mainfrom
142-cli-tests

Conversation

@animmosmith

Copy link
Copy Markdown
Collaborator

Summary

First pass at #142. The issue noted TensorFlow had problems running in a pytest environment back in 2023 — that no longer reproduces with current TF/Keras versions (confirmed pyopia.classify imports and runs fine under pytest in this environment), and typer.testing.CliRunner works cleanly against pyopia.cli.app.

Scoped to the simple, side-effect-light commands for this first PR:

  • generate-config for each instrument (silcam, holo, uvp)
  • modify-config

Left for a follow-up: heavier commands (process, init-project, process-realtime) that exercise full pipeline runs and downloads — these would follow the same example-data patterns already used in test_pipeline.py. Also skipped docs (calls typer.launch() to open a browser — not suitable for CI).

Test plan

  • pytest pyopia/tests/test_cli.py passes (4 passed)
  • flake8 pyopia/tests/test_cli.py clean

animmosmith and others added 2 commits June 18, 2026 15:53
First pass at #142. Confirms typer's CliRunner works cleanly under
pytest in this environment, and that the TensorFlow/pytest
incompatibility noted in the issue (filed 2023) no longer applies
with current TF/Keras versions.

Scoped to the simple, side-effect-light commands for now
(generate-config for each instrument, modify-config). Heavier
commands (process, init-project, process-realtime) that exercise
full pipeline runs and downloads are left for a follow-up, following
the example-data patterns already used in test_pipeline.py.
Adds coverage for docs, --version, init-project, process, process-realtime,
merge-mfdata, convert-raw-images, make-montage, and export-to-ecotaxa,
alongside the existing generate-config/modify-config tests.

Commands that need real particle stats/ROI images to exercise (process,
merge-mfdata, convert-raw-images, make-montage, export-to-ecotaxa) share a
single real end-to-end pipeline run against the downloaded SilCam example
image via session-scoped fixtures in conftest.py, consistent with the
real-download/real-processing approach already used in test_pipeline.py and
test_classify.py.

The --version test targets the --version option added in PR #386, which has
not yet merged into main; it will start passing once that PR lands and this
branch is rebased.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@animmosmith animmosmith linked an issue Jul 28, 2026 that may be closed by this pull request
@animmosmith animmosmith self-assigned this Jul 28, 2026
@animmosmith
animmosmith requested a review from emlynjdavies July 28, 2026 17:17
@animmosmith
animmosmith marked this pull request as ready for review July 28, 2026 17:17
@animmosmith

Copy link
Copy Markdown
Collaborator Author

Now updated with a full set of tests for all CLI options.

@emlynjdavies emlynjdavies left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test works for me locally! I was not aware of this way of defining pytest fixtures. could this be a way of helping to simplify the code in the test_* files (perhaps as a future housework issue)?

need to update version number when ready

animmosmith added a commit that referenced this pull request Jul 31, 2026
README's "Build docs locally" section now syncs the docs dependency group
via uv before building, matching the RTD config. Bumped version to 2.16.20
so this PR is ready to merge right after #394, #404, #406, #408, #410.
@animmosmith
animmosmith merged commit 79ef4b0 into main Aug 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make tests for pyopia.cli command line

2 participants