mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 21:16:27 -06:00
18706 add tests
This commit is contained in:
parent
25d334a554
commit
90cf97ee29
@ -1,8 +1,10 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.test import TestCase, override_settings
|
||||
from netaddr import IPNetwork, IPSet
|
||||
from utilities.data import string_to_ranges
|
||||
|
||||
from dcim.models import Site, SiteGroup
|
||||
from ipam.choices import *
|
||||
from ipam.models import *
|
||||
|
||||
@ -645,3 +647,54 @@ class TestVLAN(TestCase):
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
vlan.full_clean()
|
||||
|
||||
def test_vlan_group_site_validation(self):
|
||||
sitegroup = SiteGroup.objects.create(
|
||||
name='Site Group 1',
|
||||
slug='site-group-1',
|
||||
)
|
||||
sites = Site.objects.bulk_create((
|
||||
Site(
|
||||
name='Site 1',
|
||||
slug='site-1',
|
||||
),
|
||||
Site(
|
||||
name='Site 2',
|
||||
slug='site-2',
|
||||
),
|
||||
))
|
||||
sitegroup.sites.add(sites[0])
|
||||
vlangroups = VLANGroup.objects.bulk_create((
|
||||
VLANGroup(
|
||||
name='VLAN Group 1',
|
||||
slug='vlan-group-1',
|
||||
scope=sitegroup,
|
||||
scope_type=ContentType.objects.get_for_model(SiteGroup),
|
||||
),
|
||||
VLANGroup(
|
||||
name='VLAN Group 2',
|
||||
slug='vlan-group-2',
|
||||
scope=sites[0],
|
||||
scope_type=ContentType.objects.get_for_model(Site),
|
||||
),
|
||||
VLANGroup(
|
||||
name='VLAN Group 2',
|
||||
slug='vlan-group-2',
|
||||
scope=sites[1],
|
||||
scope_type=ContentType.objects.get_for_model(Site),
|
||||
),
|
||||
))
|
||||
vlan = VLAN(
|
||||
name='VLAN 1',
|
||||
vid=1,
|
||||
group=vlangroups[0],
|
||||
site=sites[0],
|
||||
)
|
||||
|
||||
# VLAN Group 0 and 1 should be valid
|
||||
vlan.full_clean()
|
||||
vlan.group = vlangroups[1]
|
||||
vlan.full_clean()
|
||||
vlan.group = vlangroups[2]
|
||||
with self.assertRaises(ValidationError):
|
||||
vlan.full_clean()
|
||||
|
Loading…
Reference in New Issue
Block a user