Skip to content

Extract test configuration crud module - #2599

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

Extract test configuration crud module#2599
akwasigroch merged 1 commit into
mainfrom
refactor/extract-test-configuration-crud

Conversation

@akwasigroch

Copy link
Copy Markdown
Collaborator

Purpose

app/crud/__init__.py is the crud monolith that apps/backend/AGENTS.md says should only shrink from here. This continues the incremental split started in #2588, #2590, #2591 and #2592, taking the TestConfiguration block out.

What Changed

  • New crud/test_configuration.py with get_test_configuration, get_test_configurations, create_test_configuration and update_test_configuration, moved verbatim from crud/__init__.py.
  • 67 lines removed from crud/__init__.py. No re-exports left behind — the old names are gone from the monolith.
  • Callers switched to direct submodule imports (from rhesis.backend.app.crud import test_configuration as test_configuration_crud): routers/test_configuration.py, services/test_run.py, services/test_set.py, jobs/execution/config.py and jobs/execution/modes.py. In services/test_set.py the call sites sit inside function-local imports, so those were adjusted in place rather than at the module header.
  • Patch targets updated in tests/backend/services/test_rescore.py and tests/backend/routes/test_execute_dispatch_task_id.py.

This is a pure move: no logic, signature or behaviour changes. Import direction stays jobs → app.

Additional Context

Two pre-existing problems surfaced while tracing callers. Neither is touched here, both are worth a separate fix:

  • routers/test_configuration.py:176 calls crud.delete_test_configuration, which does not exist anywhere in the codebase — that DELETE endpoint raises AttributeError at runtime. The router keeps its from rhesis.backend.app import crud import solely for that broken line.
  • jobs/execution/modes.py:93 reaches a schema through the crud module as crud.schemas.TestConfigurationUpdate instead of importing schemas directly.

Two sibling PRs split other blocks of the same file in parallel. They touch different line ranges and different callers.

Testing

uv run pytest tests/backend/services/test_rescore.py tests/backend/routes/test_execute_dispatch_task_id.py tests/backend/routes/test_execute_with_reuse.py tests/backend/jobs/test_execution.py tests/backend/services/test_test_set.py tests/backend/services/test_test_execution.py → 85 passed, 3 skipped (pre-existing skips).

uv run pytest tests/backend/routes/test_quota_gates.py tests/backend/security/test_organization_filtering.py tests/backend/auth/test_object_level_auth.py tests/backend/jobs/test_validation.py tests/backend/jobs/test_filter_configs_by_scope.py → 68 passed.

Ruff check and format on all touched files are at the pre-change baseline.

Continues the incremental split of the crud monolith. TestConfiguration
moves to its own module; callers switch to direct submodule imports.
Pure move -- no logic changes.
@akwasigroch
akwasigroch force-pushed the refactor/extract-test-configuration-crud branch from 87fbe8e to 58d73d9 Compare August 25, 2026 15:09
@akwasigroch
akwasigroch merged commit f069e65 into main Aug 25, 2026
15 of 17 checks passed
@akwasigroch
akwasigroch deleted the refactor/extract-test-configuration-crud branch August 25, 2026 15:11
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