Compare commits

..
3 Commits
Author SHA1 Message Date
MrBlake 8b804cb8ce Merge branch 'feat/disks'
# Conflicts:
#	netbox_utilities/__init__.py
#	pyproject.toml
2026-10-19 12:35:52 +02:00
MrBlakeandClaude Opus 5.5 2aab3d14ee Enable NetBox-Export integration for 0.3.12-0.3.14 and fix stale tests
The rack width integration only accepted NetBox-Export 0.3.11 and 0.3.14, but the published version was 0.3.13, so the patches were silently skipped. Accept 0.3.12 to 0.3.14; the patcher still checks that all hooked functions exist before patching. Verified on NetBox 4.7.2 that the patch is applied.

Update four outdated tests: compare asset versions against __version__ instead of 0.10.4, allow the read-only tenant group lookup in the connection scope test, and check the prefix column in NetBox's table column registry, where register_table_column() stores it.

All 174 tests pass on NetBox 4.7.2. Bump version to 0.14.4.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-13 15:08:43 +02:00
MrBlakeandClaude Opus 5.5 1ed16c542a Fix fresh-install migrations on PostgreSQL
Reading the runtime settings while other migrations run failed because the settings table did not exist yet. The error was caught, but it aborted the surrounding migration transaction on PostgreSQL. Run the query inside a savepoint. Verified with NetBox 4.7.2. Bump version to 0.14.3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-13 14:13:18 +02:00
6 changed files with 23 additions and 13 deletions

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ from .rack_width import (
logger = logging.getLogger(__name__)
SUPPORTED_NETBOX_EXPORT_VERSIONS = {"0.3.11", "0.3.14"}
SUPPORTED_NETBOX_EXPORT_VERSIONS = {"0.3.11", "0.3.12", "0.3.13", "0.3.14"}
RACK_WIDTH_RECORD_KEY = "netbox_utilities_rack_placement"
PATCH_MARKER = "_netbox_utilities_rack_width_version"
PATCH_VERSION = 1
+9 -6
View File
@@ -1,5 +1,5 @@
from django.core.cache import cache
from django.db import OperationalError, ProgrammingError
from django.db import OperationalError, ProgrammingError, transaction
from netbox.plugins import get_plugin_config
from .models import UtilitiesSettings
@@ -37,11 +37,14 @@ def _get_database_settings():
runtime_settings = cache.get(SETTINGS_CACHE_KEY)
if runtime_settings is None:
try:
runtime_settings = (
UtilitiesSettings.objects.filter(singleton_id=1)
.values("tenant_filter_enabled", "tenant_required")
.first()
)
# The savepoint keeps an outer transaction (e.g. a running migration)
# usable on PostgreSQL if the settings table does not exist yet.
with transaction.atomic():
runtime_settings = (
UtilitiesSettings.objects.filter(singleton_id=1)
.values("tenant_filter_enabled", "tenant_required")
.first()
)
except (OperationalError, ProgrammingError):
# The middleware can be imported before the first plugin migration.
runtime_settings = None
@@ -37,6 +37,9 @@ class _Form(forms.Form):
class ConnectionScopeFieldTest(SimpleTestCase):
# Pre-filling the tenant also looks up the tenant group (read-only query).
databases = {"default"}
def test_filter_fields_are_optional_and_chained(self):
fields = build_filter_fields()
+2 -1
View File
@@ -8,6 +8,7 @@ from django.test import RequestFactory, SimpleTestCase
from django.urls import resolve, reverse
from rest_framework.exceptions import PermissionDenied
import netbox_utilities
from netbox_utilities.reorder_rack import (
RackLayoutError,
apply_rack_layout,
@@ -449,7 +450,7 @@ class ReorderRackFrontendTest(SimpleTestCase):
self.assertEqual(template_name, "netbox_utilities/reorder_rack.html")
self.assertEqual(context["reorder_devices"][0]["label"], "LEO-Fritzbox")
self.assertEqual(context["reorder_devices"][0]["grid_width"], 6)
self.assertEqual(context["asset_version"], "0.10.4")
self.assertEqual(context["asset_version"], netbox_utilities.__version__)
self.assertIs(context["reorder_rack_width_data"], get_width_data.return_value)
get_width_data.assert_called_once()
self.assertIs(get_width_data.call_args.kwargs["rack"], rack)
+6 -4
View File
@@ -72,11 +72,13 @@ class SitePrefixTest(SimpleTestCase):
def test_device_and_rack_tables_offer_prefix_column(self):
from dcim.tables import DeviceTable, RackTable
self.assertIn(COLUMN_NAME, DeviceTable.base_columns)
self.assertIn(COLUMN_NAME, RackTable.base_columns)
from netbox.registry import registry
# register_table_column() stores columns in the registry; NetBox adds them when a table is instantiated.
for table in (DeviceTable, RackTable):
column = table.base_columns[COLUMN_NAME]
self.assertTrue(column.orderable)
self.assertIn(COLUMN_NAME, registry["tables"][table])
column = registry["tables"][table][COLUMN_NAME]
self.assertIsNot(column.orderable, False) # None means the table default (sortable)
self.assertEqual(tuple(column.order_by), ("site__name",))
self.assertEqual(DeviceTable.Meta.default_columns[:2], ("pk", COLUMN_NAME))
self.assertEqual(RackTable.Meta.default_columns[:2], ("pk", COLUMN_NAME))
@@ -5,6 +5,7 @@ from unittest.mock import MagicMock, patch
from django.http import HttpResponse
from django.test import RequestFactory, SimpleTestCase
import netbox_utilities
from netbox_utilities.topology_views import (
_apply_topology_widths_to_device_tags,
_inject_topology_widths,
@@ -246,7 +247,7 @@ class TopologyViewsRackWidthTest(SimpleTestCase):
self.assertIn('id="netbox-utilities-topology-rack-width-styles"', html)
self.assertIn('.rack-device[href="/dcim/devices/334/"]', html)
self.assertIn("left: calc(50% + 3px) !important", html)
self.assertIn("netbox_utilities/topology-rack-width.js?v=0.10.4", html)
self.assertIn(f"netbox_utilities/topology-rack-width.js?v={netbox_utilities.__version__}", html)
self.assertIn("left:calc(0% + 3px)!important", html)
self.assertIn("left:calc(50% + 3px)!important", html)
self.assertIn("width:calc(50% - 6px)!important", html)