[PR #20302] [MERGED] Closes #19944: Add multi-scenario CSV import testing support with cleanup #15882

Closed
opened 2025-12-30 00:24:35 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20302
Author: @jnovinger
Created: 9/9/2025
Status: Merged
Merged: 9/11/2025
Merged by: @jeremystretch

Base: mainHead: 19944-expanded-csv-scenario-testing


📝 Commits (6)

  • ba1c7b4 Closes #19944: Add multi-scenario CSV import testing support with cleanup
  • 362be89 Fixup ModuleTypeTestCase bulk import test to work with callback mechamisn
  • 7cf0a9b Update CableTestCase to use expanded CSV scenario testing
  • 9690528 Merge branch 'main' into 19944-expanded-csv-scenario-testing
  • abb274d Remove unneeded permission cleanup
  • c7e9a83 Consolidate scenario name retrieval into method

📊 Changes

3 files changed (+173 additions, -55 deletions)

View changed files

📝 netbox/dcim/tests/test_views.py (+48 -19)
📝 netbox/utilities/testing/base.py (+16 -0)
📝 netbox/utilities/testing/views.py (+109 -36)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/20302 **Author:** [@jnovinger](https://github.com/jnovinger) **Created:** 9/9/2025 **Status:** ✅ Merged **Merged:** 9/11/2025 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `main` ← **Head:** `19944-expanded-csv-scenario-testing` --- ### 📝 Commits (6) - [`ba1c7b4`](https://github.com/netbox-community/netbox/commit/ba1c7b444a3cdf26efb8d941ca611754597687e7) Closes #19944: Add multi-scenario CSV import testing support with cleanup - [`362be89`](https://github.com/netbox-community/netbox/commit/362be89ec5a7ed863a5aaa679712ca114b1ad5d0) Fixup ModuleTypeTestCase bulk import test to work with callback mechamisn - [`7cf0a9b`](https://github.com/netbox-community/netbox/commit/7cf0a9b23d0ef0de4f109ec8aba743f195ed8a0a) Update CableTestCase to use expanded CSV scenario testing - [`9690528`](https://github.com/netbox-community/netbox/commit/9690528fa84d81e11262bb0c05c591c540944db8) Merge branch 'main' into 19944-expanded-csv-scenario-testing - [`abb274d`](https://github.com/netbox-community/netbox/commit/abb274dba7daca8157c01c27a89adff34b12f3b3) Remove unneeded permission cleanup - [`c7e9a83`](https://github.com/netbox-community/netbox/commit/c7e9a831d91e05e92f1df86af33095999067ae74) Consolidate scenario name retrieval into method ### 📊 Changes **3 files changed** (+173 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/tests/test_views.py` (+48 -19) 📝 `netbox/utilities/testing/base.py` (+16 -0) 📝 `netbox/utilities/testing/views.py` (+109 -36) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:24:35 +01:00
adam closed this issue 2025-12-30 00:24:35 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15882