Skip to content

refactor(test): Extract Test models into dojo/test/ module [2/10]#14971

Draft
valentijnscholten wants to merge 5 commits into
reorg/product_type-modelsfrom
reorg/test-models
Draft

refactor(test): Extract Test models into dojo/test/ module [2/10]#14971
valentijnscholten wants to merge 5 commits into
reorg/product_type-modelsfrom
reorg/test-models

Conversation

@valentijnscholten

@valentijnscholten valentijnscholten commented Jun 7, 2026

Copy link
Copy Markdown
Member

Stacked PRs

This is one of a stacked series that reorganizes dojo/ into self-contained dojo/{module}/ packages (matching the dojo/url/ reference). They are stacked — each PR is based on the previous one — so review and merge bottom-up in this order:

  1. refactor(product_type): Extra ProductType models into dojo/product_type/ module [1/10] #14970 — product_type
  2. refactor(test): Extract Test models into dojo/test/ module [2/10] #14971 — test ◀ this PR
  3. refactor(engagement): Extract Test models into dojo/test/ module [3/10] #14972 — engagement
  4. refactor(product): Extract Product module into dojo/product/ [4/10] #14973 — product
  5. refactor(finding): Reorganize finding into self-contained dojo/finding/ package [5/10] #14974 — finding (+ CWE & BurpRawRequestResponse fold-in)
  6. refactor(reorg): extract user + system_settings modules [6/10] #14981 — peripheral: user + system_settings
  7. refactor(reorg): extract endpoint + tool_type/tool_config/tool_product modules [7/10] #14982 — peripheral: endpoint + tool_type/tool_config/tool_product
  8. refactor(reorg): extract survey + benchmark modules [8/10] #14983 — peripheral: survey + benchmark
  9. refactor(reorg): extract notes/note_type/file_uploads/reports/risk_acceptance [9/10] #14986 — peripheral: notes/note_type + file_uploads + reports + risk_acceptance
  10. refactor(reorg): extract regulations/banner/announcement/development_environment/object [10/10] #14987 — peripheral: regulations + banner + announcement + development_environment + object

Merge #14970 first; each following branch is rebased onto the updated base and merged in turn. PRs 6–10 (draft, head branches on the DefectDojo upstream repo) continue the stack on top of #14974 — full implementation brief is the Phase 10 section in AGENTS.md.

Summary

Fully reorganizes the Test domain into a self-contained dojo/test/ package — models, services, UI, and API.

  • Models: Test, Test_Type, Test_Import, Test_Import_Finding_Action + admin into dojo/test/{models,admin}.py; string FK refs; IMPORT_* constants single-sourced + re-exported. No migration change.
  • Services: extract the test copy workflow (clone into engagement + grade recalc + notification) into an HTTP-free copy_test(test, engagement, user) service; view thinned; unit test added.
  • UI: forms → ui/forms.py (TestForm re-exported since engagement uses it); test-domain filters (TestImportFilter, TestImportFindingActionFilter, TestTypeFilter) → ui/filters.py keeping DojoFilter bases (re-exports omitted to avoid cycle; consumers updated). EngagementTest* filters left for the engagement module. Views + urls → ui/.
  • API: 8 Test-domain serializers → api/serializer.py (TestSerializer re-exported for reports; rest omitted); ApiTestFilter/TestImportAPIFilterapi/filters.py; TestsViewSet/TestTypesViewSet/TestImportViewSetapi/views.py; api/urls.py adds add_test_urls() preserving routes tests/test_types/test_imports + basenames. Finding* serializers left in place.

Verified: manage.py check, makemigrations --check (no changes), ruff, copy/apply-template tests, and the full rest_framework suite (871 tests).

@valentijnscholten valentijnscholten changed the title refactor(test): extract Test models into dojo/test/ [Phase 1, 2/5] refactor(test): extract Test models into dojo/test/ [2/5] Jun 7, 2026
@valentijnscholten valentijnscholten changed the title refactor(test): extract Test models into dojo/test/ [2/5] refactor(test): self-contained dojo/test/ module [2/5] Jun 7, 2026
@valentijnscholten valentijnscholten changed the title refactor(test): self-contained dojo/test/ module [2/5] refactor(test): Extract Test models into dojo/test/ module [2/5] Jun 7, 2026
…est/

Phase 1 of module reorg per AGENTS.md. Move Test, Test_Type, Test_Import,
Test_Import_Finding_Action + admin registrations into dojo/test/{models,admin}.py.
Cross-module FKs use string refs to avoid circular imports; IMPORT_* action
constants single-sourced in dojo/test/models.py with re-export in dojo/models.py.
No migration change.
…se 2]

Move the test copy workflow (clone into engagement + product grade recalc +
notification) out of the copy_test view into an HTTP-free copy_test(test,
engagement, user) service, mirroring copy_engagement. View thinned to call it.
Add a unit test for the service (was previously untested). Notification URL uses
relative reverse() per codebase convention.
…e 3,4]

Move TestForm/DeleteTestForm/CopyTestForm into ui/forms.py (TestForm re-exported
from dojo/forms.py since engagement views use it; the other two have no external
consumers). Move TestImportFilter/TestImportFindingActionFilter/TestTypeFilter into
ui/filters.py keeping DojoFilter bases; re-exports omitted (would cycle) and
consumers (test/finding/test_type views) updated to the new path. EngagementTest*
filters left in dojo/filters.py (engagement domain); Api* filters left for Phase 7.
Move dojo/test/{views,urls}.py to dojo/test/ui/ and update consumers
(dojo/urls.py include + test_apply_finding_template test). urls.py now imports
views from dojo.test.ui.
…,8,9]

Move 8 Test-domain serializers into api/serializer.py (TestSerializer re-exported
from api_v2/serializers.py for ReportGenerateSerializer; rest omitted, sole consumers
were the moved viewsets), ApiTestFilter/TestImportAPIFilter into api/filters.py, and
TestsViewSet/TestTypesViewSet/TestImportViewSet into api/views.py. api/urls.py adds
add_test_urls() preserving routes tests/test_types/test_imports + basenames
test/test_type/test_imports. Viewset re-exports omitted (would cycle); dojo/urls.py +
test_rest_framework updated. Finding* serializers left in place.
Full rest_framework suite green (871 tests).
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.

1 participant