From 0985ef43d36f532f1d0c14772760b8c91c0162d8 Mon Sep 17 00:00:00 2001 From: Brian Tiemann Date: Mon, 21 Oct 2024 19:40:31 -0400 Subject: [PATCH] View tests --- netbox/ipam/forms/model_forms.py | 2 +- netbox/ipam/tests/test_views.py | 49 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py index c7df54df5..32ccfe848 100644 --- a/netbox/ipam/forms/model_forms.py +++ b/netbox/ipam/forms/model_forms.py @@ -702,7 +702,7 @@ class VLANTranslationPolicyForm(NetBoxModelForm): class Meta: model = VLANTranslationPolicy fields = [ - 'name', 'description', + 'name', 'description', 'tags', ] diff --git a/netbox/ipam/tests/test_views.py b/netbox/ipam/tests/test_views.py index 27d88767b..8f9162436 100644 --- a/netbox/ipam/tests/test_views.py +++ b/netbox/ipam/tests/test_views.py @@ -863,6 +863,55 @@ class VLANTestCase(ViewTestCases.PrimaryObjectViewTestCase): } +class VLANTranslationPolicyTestCase(ViewTestCases.PrimaryObjectViewTestCase): + model = VLANTranslationPolicy + + @classmethod + def setUpTestData(cls): + + vlan_translation_policies = ( + VLANTranslationPolicy( + name='Policy 1', + description='foobar1', + ), + VLANTranslationPolicy( + name='Policy 2', + description='foobar2', + ), + VLANTranslationPolicy( + name='Policy 3', + description='foobar3', + ), + ) + VLANTranslationPolicy.objects.bulk_create(vlan_translation_policies) + + tags = create_tags('Alpha', 'Bravo', 'Charlie') + + cls.form_data = { + 'name': 'Policy999', + 'description': 'A new VLAN Translation Policy', + 'tags': [t.pk for t in tags], + } + + cls.csv_data = ( + "name,description", + "Policy101,foobar1", + "Policy102,foobar2", + "Policy103,foobar3", + ) + + cls.csv_update_data = ( + "id,name,description", + f"{vlan_translation_policies[0].pk},Policy101,New description 1", + f"{vlan_translation_policies[1].pk},Policy102,New description 2", + f"{vlan_translation_policies[2].pk},Policy103,New description 3", + ) + + cls.bulk_edit_data = { + 'description': 'New description', + } + + class ServiceTemplateTestCase(ViewTestCases.PrimaryObjectViewTestCase): model = ServiceTemplate