From 54b9d1b3f235b8212c73717173e1e7aa7e638b6e Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 1 Mar 2024 14:37:32 -0500 Subject: [PATCH] Disconnect search backend during test to avoid discrepancy with ContentTypes on transaction rollback --- netbox/netbox/tests/test_staging.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/netbox/netbox/tests/test_staging.py b/netbox/netbox/tests/test_staging.py index ed3a69f10..0a73b2987 100644 --- a/netbox/netbox/tests/test_staging.py +++ b/netbox/netbox/tests/test_staging.py @@ -1,9 +1,11 @@ +from django.db.models.signals import post_save from django.test import TransactionTestCase from circuits.models import Provider, Circuit, CircuitType from extras.choices import ChangeActionChoices from extras.models import Branch, StagedChange, Tag from ipam.models import ASN, RIR +from netbox.search.backends import search_backend from netbox.staging import checkout from utilities.testing import create_tags @@ -11,6 +13,10 @@ from utilities.testing import create_tags class StagingTestCase(TransactionTestCase): def setUp(self): + # Disconnect search backend to avoid issues with cached ObjectTypes being deleted + # from the database upon transaction rollback + post_save.disconnect(search_backend.caching_handler) + create_tags('Alpha', 'Bravo', 'Charlie') rir = RIR.objects.create(name='RIR 1', slug='rir-1')