Skip to content

Extract test result CRUD out of the crud/__init__.py monolith - #2588

Merged
akwasigroch merged 1 commit into
mainfrom
refactor/extract-test-result-crud
Aug 25, 2026
Merged

Extract test result CRUD out of the crud/__init__.py monolith#2588
akwasigroch merged 1 commit into
mainfrom
refactor/extract-test-result-crud

Conversation

@akwasigroch

Copy link
Copy Markdown
Collaborator

Purpose

Next step in the incremental split of the crud monolith, continuing the series from #2410 through #2458. crud/__init__.py only shrinks from here, per the crud-layout rule in apps/backend/AGENTS.md.

Test Result was picked deliberately over the larger remaining blocks. Every branch currently in flight that touches crud/__init__.py#2446 plus the local metric-tuning branches — modifies the same three spots: the import block, get_test_sets, and get_tests. Extracting TestSet or Test next would land right on top of them. Test Result sits below all three, needs no change to the import block, and has no cross-references from anywhere else in the module, so it lifts out cleanly. git merge-tree against #2446's branch reports no conflicts.

What Changed

  • New app/crud/test_result.py holding get_test_result, get_test_results, create_test_result, update_test_result, delete_test_result, and the _TEST_RESULT_RELATED_FIELDS eager-load tuple. Bodies moved verbatim; no behaviour change.
  • crud/__init__.py drops the 76-line Test Result section (1412 → 1336 lines). Its import block is untouched, so the line the in-flight branches add there stays clean.
  • Callers switched to the house pattern used by the already-extracted modules, from rhesis.backend.app.crud import test_result as test_result_crud: routers/test_result.py (10 sites), tasks/execution/executors/results.py (2), tasks/execution/executors/output_providers.py (1), services/test_run.py (1).
  • crud dropped from the top-level import in the three files where every use of it was a test-result call. services/test_run.py keeps it — it still reaches for test, prompt and test_configuration.
  • Tests: 12 patch() targets retargeted from ...crud.get_test_result to ...test_result_crud.get_test_result, 4 direct calls updated, and 2 now-unused crud imports removed.

Additional Context

Testing

cd apps/backend
uv sync --extra all --extra ee
uv run pytest ../../tests/backend/tasks/ ../../tests/backend/crud/ ../../tests/backend/routes/ ../../tests/backend/auth/ ../../tests/backend/services/ ../../tests/backend/security/ ../../tests/backend/metrics/

4520 passed, 42 skipped, 1 xfailed locally — that covers every test that touches test results, including the retargeted mock patches, which would fail loudly with AttributeError if a patch target had gone stale. Ruff check and format are clean on all touched files.

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.

1 participant