Add tests for study state transitions
@becky-gilbert is already working on this.
Since Feb 12, 2026.
- Dominant language
- Python
- Stars
- 12
- Forks
- 21
- Avg merge
- 5d 19h
- Merged PRs (30d)
- 5
Description
## Description
We don't have a full set of tests to cover study state transitions and monitoring fields. While adding a feature to automatically pause studies when the response limit is reach, I wrote tests that revealed that studies can be auto-rejected even when the user did not change any of the monitoring fields. This is because our current tests that set study.state = "active" also all use G() and explicitly provide image=SimpleUploadedFile(...). With a real file, both the in-memory and DB-loaded ImageFieldFile have the same non-empty .name string, so the comparison works fine. But when a test uses minimal study creation (Study.objects.create() with only name, lab, study_type, and max_responses — leaving image unset), this triggers a mismatch due to Image = None (the in-memory default) vs '' (loaded from database).
This bug isn't a major practical issue since the image field is required in the form (even though Null is allowed in the model). But the fact that it went unnoticed shows that we don't have optimal test coverage for the `check_modification_of_approved_study` method and possibly other study states/transitions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.