Skip to content

Commit

Permalink
updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mencken-d committed Nov 25, 2024
1 parent 6fdbd1a commit 816be31
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
Empty file added netbox_rpki/tests/__init__.py
Empty file.
54 changes: 54 additions & 0 deletions netbox_rpki/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion netbox_rpki/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 816be31

Please sign in to comment.