mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 09:28:38 -06:00
Add missing tests for SiteGroup
This commit is contained in:
parent
7885ec5511
commit
bfa95c16e3
@ -86,6 +86,35 @@ class RegionTest(APIViewTestCases.APIViewTestCase):
|
|||||||
Region.objects.create(name='Region 3', slug='region-3')
|
Region.objects.create(name='Region 3', slug='region-3')
|
||||||
|
|
||||||
|
|
||||||
|
class SiteGroupTest(APIViewTestCases.APIViewTestCase):
|
||||||
|
model = SiteGroup
|
||||||
|
brief_fields = ['_depth', 'display', 'id', 'name', 'site_count', 'slug', 'url']
|
||||||
|
create_data = [
|
||||||
|
{
|
||||||
|
'name': 'Site Group 4',
|
||||||
|
'slug': 'site-group-4',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Site Group 5',
|
||||||
|
'slug': 'site-group-5',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Site Group 6',
|
||||||
|
'slug': 'site-group-6',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
bulk_update_data = {
|
||||||
|
'description': 'New description',
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(cls):
|
||||||
|
|
||||||
|
SiteGroup.objects.create(name='Site Group 1', slug='site-group-1')
|
||||||
|
SiteGroup.objects.create(name='Site Group 2', slug='site-group-2')
|
||||||
|
SiteGroup.objects.create(name='Site Group 3', slug='site-group-3')
|
||||||
|
|
||||||
|
|
||||||
class SiteTest(APIViewTestCases.APIViewTestCase):
|
class SiteTest(APIViewTestCases.APIViewTestCase):
|
||||||
model = Site
|
model = Site
|
||||||
brief_fields = ['display', 'id', 'name', 'slug', 'url']
|
brief_fields = ['display', 'id', 'name', 'slug', 'url']
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Platform, Site, Region
|
from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Platform, Region, Site, SiteGroup
|
||||||
from extras.models import ConfigContext, Tag
|
from extras.models import ConfigContext, Tag
|
||||||
from tenancy.models import Tenant, TenantGroup
|
from tenancy.models import Tenant, TenantGroup
|
||||||
from virtualization.models import Cluster, ClusterGroup, ClusterType, VirtualMachine
|
from virtualization.models import Cluster, ClusterGroup, ClusterType, VirtualMachine
|
||||||
@ -28,7 +28,8 @@ class ConfigContextTest(TestCase):
|
|||||||
self.devicetype = DeviceType.objects.create(manufacturer=manufacturer, model='Device Type 1', slug='device-type-1')
|
self.devicetype = DeviceType.objects.create(manufacturer=manufacturer, model='Device Type 1', slug='device-type-1')
|
||||||
self.devicerole = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1')
|
self.devicerole = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1')
|
||||||
self.region = Region.objects.create(name="Region")
|
self.region = Region.objects.create(name="Region")
|
||||||
self.site = Site.objects.create(name='Site-1', slug='site-1', region=self.region)
|
self.sitegroup = SiteGroup.objects.create(name="Site Group")
|
||||||
|
self.site = Site.objects.create(name='Site-1', slug='site-1', region=self.region, group=self.sitegroup)
|
||||||
self.platform = Platform.objects.create(name="Platform")
|
self.platform = Platform.objects.create(name="Platform")
|
||||||
self.tenantgroup = TenantGroup.objects.create(name="Tenant Group")
|
self.tenantgroup = TenantGroup.objects.create(name="Tenant Group")
|
||||||
self.tenant = Tenant.objects.create(name="Tenant", group=self.tenantgroup)
|
self.tenant = Tenant.objects.create(name="Tenant", group=self.tenantgroup)
|
||||||
@ -160,6 +161,14 @@ class ConfigContextTest(TestCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
region_context.regions.add(self.region)
|
region_context.regions.add(self.region)
|
||||||
|
sitegroup_context = ConfigContext.objects.create(
|
||||||
|
name="sitegroup",
|
||||||
|
weight=100,
|
||||||
|
data={
|
||||||
|
"sitegroup": 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
sitegroup_context.site_groups.add(self.sitegroup)
|
||||||
platform_context = ConfigContext.objects.create(
|
platform_context = ConfigContext.objects.create(
|
||||||
name="platform",
|
name="platform",
|
||||||
weight=100,
|
weight=100,
|
||||||
@ -224,6 +233,14 @@ class ConfigContextTest(TestCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
region_context.regions.add(self.region)
|
region_context.regions.add(self.region)
|
||||||
|
sitegroup_context = ConfigContext.objects.create(
|
||||||
|
name="sitegroup",
|
||||||
|
weight=100,
|
||||||
|
data={
|
||||||
|
"sitegroup": 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
sitegroup_context.site_groups.add(self.sitegroup)
|
||||||
platform_context = ConfigContext.objects.create(
|
platform_context = ConfigContext.objects.create(
|
||||||
name="platform",
|
name="platform",
|
||||||
weight=100,
|
weight=100,
|
||||||
|
Loading…
Reference in New Issue
Block a user