mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-20 19:19:22 -06:00
Make filter test logic more obvious
This commit is contained in:
parent
c28684a8b3
commit
bc696f2e11
@ -3,6 +3,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from dcim.models import DeviceRole, Platform, Region, Site
|
from dcim.models import DeviceRole, Platform, Region, Site
|
||||||
from extras.choices import *
|
from extras.choices import *
|
||||||
|
from extras.constants import GRAPH_MODELS
|
||||||
from extras.filters import *
|
from extras.filters import *
|
||||||
from extras.models import ConfigContext, ExportTemplate, Graph
|
from extras.models import ConfigContext, ExportTemplate, Graph
|
||||||
from tenancy.models import Tenant, TenantGroup
|
from tenancy.models import Tenant, TenantGroup
|
||||||
@ -15,7 +16,8 @@ class GraphTestCase(TestCase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
|
|
||||||
content_types = ContentType.objects.filter(model__in=['site', 'device', 'interface'])
|
# Get the first three available types
|
||||||
|
content_types = ContentType.objects.filter(GRAPH_MODELS)[:3]
|
||||||
|
|
||||||
graphs = (
|
graphs = (
|
||||||
Graph(name='Graph 1', type=content_types[0], template_language=TemplateLanguageChoices.LANGUAGE_DJANGO, source='http://example.com/1'),
|
Graph(name='Graph 1', type=content_types[0], template_language=TemplateLanguageChoices.LANGUAGE_DJANGO, source='http://example.com/1'),
|
||||||
@ -29,7 +31,8 @@ class GraphTestCase(TestCase):
|
|||||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||||
|
|
||||||
def test_type(self):
|
def test_type(self):
|
||||||
params = {'type': ContentType.objects.get(model='site').pk}
|
content_type = ContentType.objects.filter(GRAPH_MODELS).first()
|
||||||
|
params = {'type': content_type.pk}
|
||||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||||
|
|
||||||
# TODO: Remove in v2.8
|
# TODO: Remove in v2.8
|
||||||
|
Loading…
Reference in New Issue
Block a user