Test test_content_type fails due to 2 content type site models #4209

Closed
opened 2025-12-29 18:33:52 +01:00 by adam · 2 comments
Owner

Originally created by @bloomcake on GitHub (Oct 23, 2020).

Environment

  • Python version: 3.8.6
  • NetBox version: 2.9.7

Steps to Reproduce

  1. run tests for this test case coverage run --source="netbox/" manage.py test extras.tests.test_filters.ExportTemplateTestCase
  2. test_content_type will fail with django.contrib.contenttypes.models.ContentType.MultipleObjectsReturned: get() returned more than one ContentType -- it returned 2!
  3. some debug print(ContentType.objects.filter(model='site').all()): <QuerySet [<ContentType: sites | site>, <ContentType: dcim | site>]> there are site models for app sites and dcim

Expected Behavior

I'm not sure, either assertEqual should check for 2 or find out why there are two content types with the site model.

Observed Behavior

The following test fails, because there are two content types with the model site extras.tests.test_filters.ExportTemplateTestCase.test_content_type

Originally created by @bloomcake on GitHub (Oct 23, 2020). ### Environment * Python version: 3.8.6 * NetBox version: 2.9.7 ### Steps to Reproduce 1. run tests for this test case `coverage run --source="netbox/" manage.py test extras.tests.test_filters.ExportTemplateTestCase` 2. `test_content_type` will fail with `django.contrib.contenttypes.models.ContentType.MultipleObjectsReturned: get() returned more than one ContentType -- it returned 2!` 3. some debug `print(ContentType.objects.filter(model='site').all())`: `<QuerySet [<ContentType: sites | site>, <ContentType: dcim | site>]>` there are site models for app `sites` and `dcim` ### Expected Behavior I'm not sure, either assertEqual should check for 2 or find out why there are two content types with the site model. ### Observed Behavior The following test fails, because there are two content types with the model site `extras.tests.test_filters.ExportTemplateTestCase.test_content_type`
adam closed this issue 2025-12-29 18:33:52 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 23, 2020):

These tests are run by CI/CD on every commit to master. You can see here that they all pass. So, what's different between your local setup and the master branch? (Hint: NetBox doesn't use the sites app.)

@jeremystretch commented on GitHub (Oct 23, 2020): These tests are run by CI/CD on every commit to `master`. You can see [here](https://github.com/netbox-community/netbox/runs/1242525775) that they all pass. So, what's different between your local setup and the master branch? (Hint: NetBox doesn't use the `sites` app.)
Author
Owner

@jeremystretch commented on GitHub (Oct 30, 2020):

Closing due to lack of activity.

@jeremystretch commented on GitHub (Oct 30, 2020): Closing due to lack of activity.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4209