12552 test fixes

This commit is contained in:
Arthur 2023-05-24 16:55:43 -07:00
parent ff9a9d914f
commit a8c9d87a5c
2 changed files with 3 additions and 3 deletions

View File

@ -22,8 +22,8 @@ def handle_location_site_change(instance, created, **kwargs):
object instead of calling update() on the QuerySet to ensure the proper change records get created for each. object instead of calling update() on the QuerySet to ensure the proper change records get created for each.
""" """
if not created: if not created:
instance.descendants().update(site=instance.site)
locations = instance.descendants(include_self=True).values_list('pk', flat=True) locations = instance.descendants(include_self=True).values_list('pk', flat=True)
Location.objects.filter(pk__in=locations).update(site=instance.site)
Rack.objects.filter(location__in=locations).update(site=instance.site) Rack.objects.filter(location__in=locations).update(site=instance.site)
Device.objects.filter(location__in=locations).update(site=instance.site) Device.objects.filter(location__in=locations).update(site=instance.site)
PowerPanel.objects.filter(location__in=locations).update(site=instance.site) PowerPanel.objects.filter(location__in=locations).update(site=instance.site)

View File

@ -2,7 +2,7 @@ import django_filters
from django.conf import settings from django.conf import settings
from django.db import models from django.db import models
from django.test import TestCase from django.test import TestCase
from mptt.fields import TreeForeignKey from tree_queries.fields import TreeNodeForeignKey
from taggit.managers import TaggableManager from taggit.managers import TaggableManager
from dcim.choices import * from dcim.choices import *
@ -94,7 +94,7 @@ class DummyModel(models.Model):
integerfield = models.IntegerField() integerfield = models.IntegerField()
macaddressfield = MACAddressField() macaddressfield = MACAddressField()
timefield = models.TimeField() timefield = models.TimeField()
treeforeignkeyfield = TreeForeignKey( treeforeignkeyfield = TreeNodeForeignKey(
to='self', to='self',
on_delete=models.CASCADE on_delete=models.CASCADE
) )