fix: render tenancy fields in license form

Define an explicit tenancy fieldset and bump the package version to 1.9.1 so Git/Pip upgrades replace older installations.
This commit is contained in:
2026-07-24 15:34:01 +02:00
parent e1c817229b
commit 7ca670c717
5 changed files with 45 additions and 2 deletions
+9
View File
@@ -1,4 +1,5 @@
from django.core.exceptions import ValidationError
from netbox_slm.forms import SoftwareLicenseForm
from tenancy.models import Tenant, TenantGroup
from .base import SlmBaseTestCase
@@ -64,6 +65,14 @@ class ModelTestCase(SlmBaseTestCase):
self.assertEqual(self.tenant_group, self.software_license.tenant_group)
self.assertEqual(self.tenant, self.software_license.tenant)
def test_software_license_form_renders_tenancy_fields(self):
form = SoftwareLicenseForm(instance=self.software_license)
self.assertIn("tenant_group", form.fields)
self.assertIn("tenant", form.fields)
self.assertTrue(
any("tenant_group" in fieldset.items and "tenant" in fieldset.items for fieldset in form.fieldsets)
)
def test_software_license_rejects_tenant_from_other_group(self):
other_group = TenantGroup.objects.create(name="other group", slug="other-group")
other_tenant = Tenant.objects.create(name="other tenant", slug="other-tenant", group=other_group)