fix: asset tenant column falls back to the hardware's tenant
The tenant column of the netbox-inventory asset list stayed empty for assets without their own tenant. It now shows the tenant of the assigned device, module, inventory item or rack instead. reportlab is pinned below 5, which pulled in pillow 13 and broke netbox-documentation's pillow<13 requirement. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
f86306e686
commit
204bb235a4
4 files changed
+54
-7
No files matched your search
@@ -23,3 +23,18 @@ class AssetTenantColumnTest(SimpleTestCase):
|
||||
add_to_default_columns(table)
|
||||
|
||||
self.assertEqual(table.Meta.default_columns, ("pk", "name", "tenant"))
|
||||
|
||||
|
||||
class AssetTenantFallbackTest(SimpleTestCase):
|
||||
def test_own_tenant_wins_then_hardware_then_hardware_device(self):
|
||||
from netbox_utilities.inventory_assets import asset_tenant
|
||||
|
||||
def asset(**kwargs):
|
||||
values = dict(tenant=None, device=None, module=None, inventoryitem=None, rack=None)
|
||||
return SimpleNamespace(**{**values, **kwargs})
|
||||
|
||||
self.assertEqual(asset_tenant(asset(tenant="A", device=SimpleNamespace(tenant="B"))), "A")
|
||||
self.assertEqual(asset_tenant(asset(device=SimpleNamespace(tenant="B"))), "B")
|
||||
module = SimpleNamespace(device=SimpleNamespace(tenant="C"))
|
||||
self.assertEqual(asset_tenant(asset(module=module)), "C")
|
||||
self.assertIsNone(asset_tenant(asset()))
|
||||
Reference in new issue
Block a user