From aaa19fd715f0418b94dc6e585882ef05f333a98f Mon Sep 17 00:00:00 2001 From: Anton M Date: Wed, 29 May 2024 23:34:32 +0200 Subject: [PATCH] move PluginTemplateExtension into netbox_changes --- validity/netbox_changes/current.py | 1 + validity/netbox_changes/oldest.py | 1 + validity/template_content.py | 2 +- validity/tests/factories.py | 1 + validity/tests/test_views.py | 8 ++++++++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/validity/netbox_changes/current.py b/validity/netbox_changes/current.py index 97895e6..d08529b 100644 --- a/validity/netbox_changes/current.py +++ b/validity/netbox_changes/current.py @@ -7,6 +7,7 @@ FieldSet = __locate("utilities.forms.rendering.FieldSet") plugins = __locate("netbox.plugins") ButtonColorChoices = __locate("netbox.choices.ButtonColorChoices") +PluginTemplateExtension = __locate("netbox.plugins.PluginTemplateExtension") CF_OBJ_TYPE = "related_object_type" CF_CONTENT_TYPES = "object_types" diff --git a/validity/netbox_changes/oldest.py b/validity/netbox_changes/oldest.py index 1558664..c626c3a 100644 --- a/validity/netbox_changes/oldest.py +++ b/validity/netbox_changes/oldest.py @@ -8,6 +8,7 @@ BootstrapMixin = __locate("utilities.forms.BootstrapMixin") plugins = __locate("extras.plugins") ButtonColorChoices = __locate("utilities.choices.ButtonColorChoices") +PluginTemplateExtension = __locate("extras.plugins.PluginTemplateExtension") class FieldSet: diff --git a/validity/template_content.py b/validity/template_content.py index 2883d13..3f6502a 100644 --- a/validity/template_content.py +++ b/validity/template_content.py @@ -1,8 +1,8 @@ import yaml from django.utils.translation import gettext_lazy as _ -from extras.plugins import PluginTemplateExtension from tenancy.models import Tenant +from validity.netbox_changes import PluginTemplateExtension from validity.pollers.result import PollingInfo diff --git a/validity/tests/factories.py b/validity/tests/factories.py index a0cb30a..def7712 100644 --- a/validity/tests/factories.py +++ b/validity/tests/factories.py @@ -18,6 +18,7 @@ class DataSourceFactory(DjangoModelFactory): name = factory.Sequence(lambda n: f"datasource-{n}") type = "local" source_url = "file:///some_path" + parameters = {} class Meta: model = models.VDataSource diff --git a/validity/tests/test_views.py b/validity/tests/test_views.py index bc34f1d..f972414 100644 --- a/validity/tests/test_views.py +++ b/validity/tests/test_views.py @@ -187,6 +187,14 @@ class TestCommand(ViewTest): } +def test_datasource_with_extensions(admin_client, create_custom_fields): + data_source = DataSourceFactory(type="device_polling") + resp = admin_client.get(data_source.get_absolute_url()) + assert resp.status_code == HTTPStatus.OK + assert b"Polling info" in resp.content + assert b"Related Objects" in resp.content + + @pytest.mark.django_db def test_datasource_devices(admin_client): data_source = DataSourceFactory(custom_field_data={"default": True})