diff --git a/netbox_rpki/tests/__init__.py b/netbox_rpki/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/netbox_rpki/tests/test_api.py b/netbox_rpki/tests/test_api.py new file mode 100644 index 0000000..66a650d --- /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 9b9b72a..5ca2f59 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,