refactor(test): Extract Test models into dojo/test/ module [2/10]#14971
Draft
valentijnscholten wants to merge 5 commits into
Draft
refactor(test): Extract Test models into dojo/test/ module [2/10]#14971valentijnscholten wants to merge 5 commits into
valentijnscholten wants to merge 5 commits into
Conversation
d5ce0b8 to
d855e36
Compare
This was referenced Jun 7, 2026
d855e36 to
a86c508
Compare
a86c508 to
43d0ea2
Compare
43d0ea2 to
af61d58
Compare
…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).
af61d58 to
a68bd0b
Compare
This was referenced Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked PRs
This is one of a stacked series that reorganizes
dojo/into self-containeddojo/{module}/packages (matching thedojo/url/reference). They are stacked — each PR is based on the previous one — so review and merge bottom-up in this order: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.Test,Test_Type,Test_Import,Test_Import_Finding_Action+ admin intodojo/test/{models,admin}.py; string FK refs;IMPORT_*constants single-sourced + re-exported. No migration change.copy_test(test, engagement, user)service; view thinned; unit test added.ui/forms.py(TestFormre-exported since engagement uses it); test-domain filters (TestImportFilter,TestImportFindingActionFilter,TestTypeFilter) →ui/filters.pykeepingDojoFilterbases (re-exports omitted to avoid cycle; consumers updated).EngagementTest*filters left for the engagement module. Views + urls →ui/.api/serializer.py(TestSerializerre-exported for reports; rest omitted);ApiTestFilter/TestImportAPIFilter→api/filters.py;TestsViewSet/TestTypesViewSet/TestImportViewSet→api/views.py;api/urls.pyaddsadd_test_urls()preserving routestests/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 fullrest_frameworksuite (871 tests).