|
| 1 | +import json |
| 2 | + |
| 3 | +from django.urls import reverse |
| 4 | +from utilities.testing import APITestCase, APIViewTestCases |
| 5 | + |
| 6 | +from tenancy.models import Tenant |
| 7 | +from dcim.models import Site, DeviceRole, DeviceType, Manufacturer, Device, Interface |
| 8 | +from ipam.models import IPAddress, ASN, RIR, Prefix |
| 9 | + |
| 10 | +from netbox_rpki.models import ( |
| 11 | + Certificate, |
| 12 | + CertificateAsn, |
| 13 | + CertificatePrefix, |
| 14 | + Roa, |
| 15 | + RoaPrefix, |
| 16 | + RoaAsn, |
| 17 | + Organization |
| 18 | +) |
| 19 | + |
| 20 | +from netbox_rpki.choices import ( |
| 21 | + CertificateStatusChoices |
| 22 | +) |
| 23 | + |
| 24 | + |
| 25 | +class OrganizationAPITestCase( |
| 26 | + APIViewTestCases.GetObjectViewTestCase, |
| 27 | + APIViewTestCases.ListObjectsViewTestCase, |
| 28 | + APIViewTestCases.CreateObjectViewTestCase, |
| 29 | + APIViewTestCases.UpdateObjectViewTestCase, |
| 30 | + APIViewTestCases.DeleteObjectViewTestCase, |
| 31 | + APIViewTestCases.GraphQLTestCase, |
| 32 | +): |
| 33 | + model = Organization |
| 34 | + view_namespace = "plugins-api:netbox_rpki" |
| 35 | + brief_fields = ["org_id", "name", "parent_rir"] |
| 36 | + graphql_base_name = "netbox_bgp_community" |
| 37 | + |
| 38 | + create_data = [ |
| 39 | + {"name": "rpki-testorg1", "org_id": "rpki-testorg1"}, |
| 40 | + {"name": "rpki-testorg2", "org_id": "rpki-testorg2"}, |
| 41 | + {"name": "rpki-testorg3", "org_id": "rpki-testorg3"}, |
| 42 | + ] |
| 43 | + |
| 44 | + bulk_update_data = { |
| 45 | + "description": "Test Community desc", |
| 46 | + } |
| 47 | + @classmethod |
| 48 | + def setUpTestData(cls): |
| 49 | + organizations = ( |
| 50 | + Organization(org_id="rpki-testorg1", name="rpki-testorg1"), |
| 51 | + Organization(org_id="rpki-testorg2", name="rpki-testorg2"), |
| 52 | + Organization(org_id="rpki-testorg3", name="rpki-testorg3"), |
| 53 | + ) |
| 54 | + Organization.objects.bulk_create(organizations) |
0 commit comments