Summary
The cascade fixtures setup_lib_db_with_score_set and setup_lib_db_with_variant now exist in two places — tests/lib/conftest.py and the newly added tests/models/conftest.py — as near-verbatim copies. De-duplicate them into a single shared definition so the two copies cannot silently diverge.
Problem
The annotation-pipeline allele refactor introduced tests/models/conftest.py, which copied the existing cascade fixtures from tests/lib/conftest.py. Both copies build the same scaffold on top of the base setup_lib_db (users/licenses):
setup_lib_db (users, licenses)
└─ setup_lib_db_with_score_set → ExperimentSet → Experiment → ScoreSet
└─ setup_lib_db_with_variant → Variant
Having two definitions of the same fixtures means a change to the scaffold (e.g. a new required column on ScoreSet, a relationship change) has to be made in both, and a miss produces tests that pass in one directory and fail — or worse, silently exercise stale state — in the other.
This is the recurring sprawl pattern in the suite: shared scenario setup gets copied into each test directory's conftest.py rather than shared from one location.
Proposed behavior
A single definition of setup_lib_db_with_score_set and setup_lib_db_with_variant is visible to both the tests/lib/ and tests/models/ suites. Pick one of:
- (a) Lift into the root
tests/conftest.py. Fixtures become available everywhere by location. Simplest mechanically.
- (b) Extract into an importable module under
tests/helpers/ (e.g. a fixtures module) that each directory's conftest.py imports. Keeps fixtures organized by what they build.
Tradeoff to settle as part of this issue: the root conftest.py scales badly and has already become a sort of catch-all dumping ground as more shared setup accrues; a tests/helpers/ module keeps things organized but makes fixture discovery an explicit import rather than pytest's location-based magic. Implementing option B would allow us to implement a more manageable fixture directory for our test infrastructure.
Acceptance criteria
Implementation notes
- The base
setup_lib_db (users/licenses) is the correct dependency root for the consolidated fixtures; do not duplicate that.
- Scope is deliberately narrow: only de-duplicate the existing cascade fixtures. The broader question of whether DB-backed object setup should move to factories or explicit scenario-builder functions is tracked separately and must not be folded in here.
- The
job_run fixture added in tests/models/conftest.py is local to the annotation-event tests for now; only promote it to the shared home if a second consumer appears.
Summary
The cascade fixtures
setup_lib_db_with_score_setandsetup_lib_db_with_variantnow exist in two places —tests/lib/conftest.pyand the newly addedtests/models/conftest.py— as near-verbatim copies. De-duplicate them into a single shared definition so the two copies cannot silently diverge.Problem
The annotation-pipeline allele refactor introduced
tests/models/conftest.py, which copied the existing cascade fixtures fromtests/lib/conftest.py. Both copies build the same scaffold on top of the basesetup_lib_db(users/licenses):Having two definitions of the same fixtures means a change to the scaffold (e.g. a new required column on
ScoreSet, a relationship change) has to be made in both, and a miss produces tests that pass in one directory and fail — or worse, silently exercise stale state — in the other.This is the recurring sprawl pattern in the suite: shared scenario setup gets copied into each test directory's
conftest.pyrather than shared from one location.Proposed behavior
A single definition of
setup_lib_db_with_score_setandsetup_lib_db_with_variantis visible to both thetests/lib/andtests/models/suites. Pick one of:tests/conftest.py. Fixtures become available everywhere by location. Simplest mechanically.tests/helpers/(e.g. afixturesmodule) that each directory'sconftest.pyimports. Keeps fixtures organized by what they build.Tradeoff to settle as part of this issue: the root
conftest.pyscales badly and has already become a sort of catch-all dumping ground as more shared setup accrues; atests/helpers/module keeps things organized but makes fixture discovery an explicit import rather than pytest's location-based magic. Implementing option B would allow us to implement a more manageable fixture directory for our test infrastructure.Acceptance criteria
setup_lib_db_with_score_setandsetup_lib_db_with_variantare defined exactly once.tests/models/conftest.py(and fromtests/lib/conftest.pyif the chosen home is elsewhere).tests/lib/andtests/models/continue to resolve these fixtures and pass unchanged.Implementation notes
setup_lib_db(users/licenses) is the correct dependency root for the consolidated fixtures; do not duplicate that.job_runfixture added intests/models/conftest.pyis local to the annotation-event tests for now; only promote it to the shared home if a second consumer appears.