closes #4368 - extras features model registration

This commit is contained in:
John Anderson
2020-03-14 03:03:22 -04:00
parent c5776d9da4
commit 9466802a95
15 changed files with 172 additions and 185 deletions

View File

@@ -8,9 +8,9 @@ from rest_framework import status
from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Platform, Rack, RackGroup, RackRole, Region, Site
from extras.api.views import ScriptViewSet
from extras.choices import *
from extras.constants import GRAPH_MODELS
from extras.models import ConfigContext, Graph, ExportTemplate, Tag
from extras.scripts import BooleanVar, IntegerVar, Script, StringVar
from extras.utils import FeatureQuerySet
from tenancy.models import Tenant, TenantGroup
from utilities.testing import APITestCase, choices_to_dict
@@ -35,7 +35,7 @@ class AppTest(APITestCase):
self.assertEqual(choices_to_dict(response.data.get('export-template:template_language')), TemplateLanguageChoices.as_dict())
# Graph
content_types = ContentType.objects.filter(GRAPH_MODELS)
content_types = ContentType.objects.filter(FeatureQuerySet('graphs').get_queryset())
graph_type_choices = {
"{}.{}".format(ct.app_label, ct.model): ct.name for ct in content_types
}

View File

@@ -3,8 +3,8 @@ from django.test import TestCase
from dcim.models import DeviceRole, Platform, Region, Site
from extras.choices import *
from extras.constants import GRAPH_MODELS
from extras.filters import *
from extras.utils import FeatureQuerySet
from extras.models import ConfigContext, ExportTemplate, Graph
from tenancy.models import Tenant, TenantGroup
from virtualization.models import Cluster, ClusterGroup, ClusterType
@@ -18,7 +18,7 @@ class GraphTestCase(TestCase):
def setUpTestData(cls):
# Get the first three available types
content_types = ContentType.objects.filter(GRAPH_MODELS)[:3]
content_types = ContentType.objects.filter(FeatureQuerySet('graphs').get_queryset())[:3]
graphs = (
Graph(name='Graph 1', type=content_types[0], template_language=TemplateLanguageChoices.LANGUAGE_DJANGO, source='http://example.com/1'),
@@ -32,7 +32,7 @@ class GraphTestCase(TestCase):
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
def test_type(self):
content_type = ContentType.objects.filter(GRAPH_MODELS).first()
content_type = ContentType.objects.filter(FeatureQuerySet('graphs').get_queryset()).first()
params = {'type': content_type.pk}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)