mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-27 19:27:33 +02:00
Update Tag.object_types to reference ObjectType
This commit is contained in:
@@ -1114,9 +1114,9 @@ class TagTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
content_types = {
|
||||
'site': ContentType.objects.get_by_natural_key('dcim', 'site'),
|
||||
'provider': ContentType.objects.get_by_natural_key('circuits', 'provider'),
|
||||
object_types = {
|
||||
'site': ObjectType.objects.get_by_natural_key('dcim', 'site'),
|
||||
'provider': ObjectType.objects.get_by_natural_key('circuits', 'provider'),
|
||||
}
|
||||
|
||||
tags = (
|
||||
@@ -1125,8 +1125,8 @@ class TagTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
Tag(name='Tag 3', slug='tag-3', color='0000ff'),
|
||||
)
|
||||
Tag.objects.bulk_create(tags)
|
||||
tags[0].object_types.add(content_types['site'])
|
||||
tags[1].object_types.add(content_types['provider'])
|
||||
tags[0].object_types.add(object_types['site'])
|
||||
tags[1].object_types.add(object_types['provider'])
|
||||
|
||||
# Apply some tags so we can filter by content type
|
||||
site = Site.objects.create(name='Site 1', slug='site-1')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.models import ObjectType
|
||||
from dcim.models import Device, DeviceRole, DeviceType, Location, Manufacturer, Platform, Region, Site, SiteGroup
|
||||
from extras.models import ConfigContext, Tag
|
||||
from tenancy.models import Tenant, TenantGroup
|
||||
@@ -22,7 +22,7 @@ class TagTest(TestCase):
|
||||
|
||||
# Create a Tag that can only be applied to Regions
|
||||
tag = Tag.objects.create(name='Tag 1', slug='tag-1')
|
||||
tag.object_types.add(ContentType.objects.get_by_natural_key('dcim', 'region'))
|
||||
tag.object_types.add(ObjectType.objects.get_by_natural_key('dcim', 'region'))
|
||||
|
||||
# Apply the Tag to a Region
|
||||
region.tags.add(tag)
|
||||
|
||||
Reference in New Issue
Block a user