Skip to content

Conversation

jnovinger
Copy link
Member

Closes #19944

  • Enhanced BulkImportObjectsViewTestCase to support multiple CSV import scenarios via dictionary format, where each scenario runs as a separate subtest with automatic cleanup. This enables testing different import configurations (e.g., with/without optional fields) in a single test run with clear output showing which scenario is being tested.
  • Introduces cleanupSubTest() context manager that uses database savepoints to automatically roll back changes between subtests, providing test isolation similar to separate test methods. This allows subtests to create/modify objects without affecting subsequent subtests in the same test method.

…anup

Enhanced BulkImportObjectsViewTestCase to support multiple CSV import scenarios via dictionary format,
where each scenario runs as a separate subtest with automatic cleanup. This enables testing different
import configurations (e.g., with/without optional fields) in a single test run with clear output
showing which scenario is being tested.

Introduces cleanupSubTest() context manager that uses database savepoints to automatically roll back
changes between subtests, providing test isolation similar to separate test methods. This allows
subtests to create/modify objects without affecting subsequent subtests in the same test method.

Added post_import_callback parameter to bulk import tests, allowing child classes to inject custom
assertions that run before database cleanup. This solves the inheritance problem where child classes
need to verify imported data but the parent's cleanup would roll back the data before assertions could
run.

The callback approach is cleaner than conditional cleanup parameters - it makes the execution timing
explicit and maintains test isolation while still allowing extensibility.
@jnovinger jnovinger marked this pull request as draft September 9, 2025 14:50
@jnovinger jnovinger marked this pull request as ready for review September 9, 2025 15:11
@jnovinger jnovinger requested review from a team and jeremystretch and removed request for a team September 9, 2025 15:11
jeremystretch
jeremystretch previously approved these changes Sep 9, 2025
Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed a minor merge conflict. Had a couple questions but approving as-is.

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
@jeremystretch jeremystretch merged commit 53d1b1a into main Sep 11, 2025
10 checks passed
@jeremystretch jeremystretch deleted the 19944-expanded-csv-scenario-testing branch September 11, 2025 16:47
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.

Enhanced CSV Scenario Testing for Bulk Import Forms
2 participants