|
|
@@ -5,8 +5,6 @@ from django.test import TestCase
|
|
|
from mptt.fields import TreeForeignKey
|
|
|
from taggit.managers import TaggableManager
|
|
|
|
|
|
-from circuits.filtersets import CircuitFilterSet, ProviderFilterSet
|
|
|
-from circuits.models import Circuit, Provider
|
|
|
from dcim.choices import *
|
|
|
from dcim.fields import MACAddressField
|
|
|
from dcim.filtersets import DeviceFilterSet, SiteFilterSet
|
|
|
@@ -15,6 +13,7 @@ from dcim.models import (
|
|
|
)
|
|
|
from extras.filters import TagFilter
|
|
|
from extras.models import TaggedItem
|
|
|
+from ipam.filtersets import ASNFilterSet
|
|
|
from ipam.models import RIR, ASN
|
|
|
from netbox.filtersets import BaseFilterSet
|
|
|
from utilities.filters import (
|
|
|
@@ -338,13 +337,14 @@ class DynamicFilterLookupExpressionTest(TestCase):
|
|
|
"""
|
|
|
@classmethod
|
|
|
def setUpTestData(cls):
|
|
|
+ rir = RIR.objects.create(name='RIR 1', slug='rir-1')
|
|
|
|
|
|
- providers = (
|
|
|
- Provider(name='Provider 1', slug='provider-1', asn=65001),
|
|
|
- Provider(name='Provider 2', slug='provider-2', asn=65101),
|
|
|
- Provider(name='Provider 3', slug='provider-3', asn=65201),
|
|
|
+ asns = (
|
|
|
+ ASN(asn=65001, rir=rir),
|
|
|
+ ASN(asn=65101, rir=rir),
|
|
|
+ ASN(asn=65201, rir=rir),
|
|
|
)
|
|
|
- Provider.objects.bulk_create(providers)
|
|
|
+ ASN.objects.bulk_create(asns)
|
|
|
|
|
|
manufacturers = (
|
|
|
Manufacturer(name='Manufacturer 1', slug='manufacturer-1'),
|
|
|
@@ -389,15 +389,6 @@ class DynamicFilterLookupExpressionTest(TestCase):
|
|
|
)
|
|
|
Site.objects.bulk_create(sites)
|
|
|
|
|
|
- rir = RIR.objects.create(name='RFC 6996', is_private=True)
|
|
|
-
|
|
|
- asns = [
|
|
|
- ASN(asn=65001, rir=rir),
|
|
|
- ASN(asn=65101, rir=rir),
|
|
|
- ASN(asn=65201, rir=rir)
|
|
|
- ]
|
|
|
- ASN.objects.bulk_create(asns)
|
|
|
-
|
|
|
asns[0].sites.add(sites[0])
|
|
|
asns[1].sites.add(sites[1])
|
|
|
asns[2].sites.add(sites[2])
|
|
|
@@ -456,19 +447,19 @@ class DynamicFilterLookupExpressionTest(TestCase):
|
|
|
|
|
|
def test_provider_asn_lt(self):
|
|
|
params = {'asn__lt': [65101]}
|
|
|
- self.assertEqual(ProviderFilterSet(params, Provider.objects.all()).qs.count(), 1)
|
|
|
+ self.assertEqual(ASNFilterSet(params, ASN.objects.all()).qs.count(), 1)
|
|
|
|
|
|
def test_provider_asn_lte(self):
|
|
|
params = {'asn__lte': [65101]}
|
|
|
- self.assertEqual(ProviderFilterSet(params, Provider.objects.all()).qs.count(), 2)
|
|
|
+ self.assertEqual(ASNFilterSet(params, ASN.objects.all()).qs.count(), 2)
|
|
|
|
|
|
def test_provider_asn_gt(self):
|
|
|
params = {'asn__lt': [65101]}
|
|
|
- self.assertEqual(ProviderFilterSet(params, Provider.objects.all()).qs.count(), 1)
|
|
|
+ self.assertEqual(ASNFilterSet(params, ASN.objects.all()).qs.count(), 1)
|
|
|
|
|
|
def test_provider_asn_gte(self):
|
|
|
params = {'asn__gte': [65101]}
|
|
|
- self.assertEqual(ProviderFilterSet(params, Provider.objects.all()).qs.count(), 2)
|
|
|
+ self.assertEqual(ASNFilterSet(params, ASN.objects.all()).qs.count(), 2)
|
|
|
|
|
|
def test_site_region_negation(self):
|
|
|
params = {'region__n': ['region-1']}
|