From 7f85a5d1794c7838e10a09dc8caee8ff4de7fd81 Mon Sep 17 00:00:00 2001 From: Marco Ceppi Date: Thu, 27 Feb 2020 08:41:54 -0500 Subject: [PATCH] Make sure tests for ContentType are properly scoped This fails because we have two "site" models - the first is the DCIM.Site and the second is Sites.site (used for allauth). Most all other queries in Netbox properly scope with app_label - this test does not. --- netbox/extras/tests/test_filters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/extras/tests/test_filters.py b/netbox/extras/tests/test_filters.py index 5ef96faa2..83e55e9b6 100644 --- a/netbox/extras/tests/test_filters.py +++ b/netbox/extras/tests/test_filters.py @@ -49,7 +49,7 @@ class ExportTemplateTestCase(TestCase): @classmethod def setUpTestData(cls): - content_types = ContentType.objects.filter(model__in=['site', 'rack', 'device']) + content_types = ContentType.objects.filter(app_label='dcim', model__in=['site', 'rack', 'device']) export_templates = ( ExportTemplate(name='Export Template 1', content_type=content_types[0], template_language=TemplateLanguageChoices.LANGUAGE_DJANGO, template_code='TESTING'), @@ -63,7 +63,7 @@ class ExportTemplateTestCase(TestCase): self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_content_type(self): - params = {'content_type': ContentType.objects.get(model='site').pk} + params = {'content_type': ContentType.objects.get(app_label='dcim', model='site').pk} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_template_language(self):