From 816be31fae4d8c4314164a84f2aa8aac971c2055 Mon Sep 17 00:00:00 2001 From: menckend Date: Mon, 25 Nov 2024 13:05:38 -0500 Subject: [PATCH] updates tests --- netbox_rpki/tests/__init__.py | 0 netbox_rpki/tests/test_api.py | 54 +++++++++++++++++++++++++++++++++++ netbox_rpki/views.py | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 netbox_rpki/tests/__init__.py create mode 100644 netbox_rpki/tests/test_api.py diff --git a/netbox_rpki/tests/__init__.py b/netbox_rpki/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/netbox_rpki/tests/test_api.py b/netbox_rpki/tests/test_api.py new file mode 100644 index 00000000..66a650da --- /dev/null +++ b/netbox_rpki/tests/test_api.py @@ -0,0 +1,54 @@ +import json + +from django.urls import reverse +from utilities.testing import APITestCase, APIViewTestCases + +from tenancy.models import Tenant +from dcim.models import Site, DeviceRole, DeviceType, Manufacturer, Device, Interface +from ipam.models import IPAddress, ASN, RIR, Prefix + +from netbox_rpki.models import ( + Certificate, + CertificateAsn, + CertificatePrefix, + Roa, + RoaPrefix, + RoaAsn, + Organization +) + +from netbox_rpki.choices import ( + CertificateStatusChoices +) + + +class OrganizationAPITestCase( + APIViewTestCases.GetObjectViewTestCase, + APIViewTestCases.ListObjectsViewTestCase, + APIViewTestCases.CreateObjectViewTestCase, + APIViewTestCases.UpdateObjectViewTestCase, + APIViewTestCases.DeleteObjectViewTestCase, + APIViewTestCases.GraphQLTestCase, +): + model = Organization + view_namespace = "plugins-api:netbox_rpki" + brief_fields = ["org_id", "name", "parent_rir"] + graphql_base_name = "netbox_bgp_community" + + create_data = [ + {"name": "rpki-testorg1", "org_id": "rpki-testorg1"}, + {"name": "rpki-testorg2", "org_id": "rpki-testorg2"}, + {"name": "rpki-testorg3", "org_id": "rpki-testorg3"}, + ] + + bulk_update_data = { + "description": "Test Community desc", + } + @classmethod + def setUpTestData(cls): + organizations = ( + Organization(org_id="rpki-testorg1", name="rpki-testorg1"), + Organization(org_id="rpki-testorg2", name="rpki-testorg2"), + Organization(org_id="rpki-testorg3", name="rpki-testorg3"), + ) + Organization.objects.bulk_create(organizations) diff --git a/netbox_rpki/views.py b/netbox_rpki/views.py index 9b9b72a1..5ca2f591 100644 --- a/netbox_rpki/views.py +++ b/netbox_rpki/views.py @@ -13,7 +13,7 @@ def get_extra_context(self, request, instance): certificateasn_table.configure(request) roa_table = tables.RoaTable(instance.roas.all()) roa_table.configure(request) - + return { 'signed_roas_table': roa_table, 'assigned_asns_table': certificateasn_table,