mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-18 05:28:16 -06:00
14637 fix tests
This commit is contained in:
parent
33d1679001
commit
59a25d6b20
@ -1,8 +1,6 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.utils import timezone
|
|
||||||
|
|
||||||
from utilities.testing import ChangeLoggedFilterSetTests
|
from utilities.testing import ChangeLoggedFilterSetTests
|
||||||
from ..choices import *
|
from ..choices import *
|
||||||
from ..filtersets import *
|
from ..filtersets import *
|
||||||
|
@ -317,10 +317,14 @@ class CableTermination(ChangeLoggedModel):
|
|||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
# Check for existing termination
|
# Check for existing termination
|
||||||
existing_termination = CableTermination.objects.exclude(cable=self.cable).filter(
|
qs = existing_termination = CableTermination.objects.filter(
|
||||||
termination_type=self.termination_type,
|
termination_type=self.termination_type,
|
||||||
termination_id=self.termination_id
|
termination_id=self.termination_id
|
||||||
).first()
|
)
|
||||||
|
if self.cable.pk:
|
||||||
|
qs = qs.exclude(cable=self.cable)
|
||||||
|
|
||||||
|
existing_termination = qs.first()
|
||||||
if existing_termination is not None:
|
if existing_termination is not None:
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
f"Duplicate termination found for {self.termination_type.app_label}.{self.termination_type.model} "
|
f"Duplicate termination found for {self.termination_type.app_label}.{self.termination_type.model} "
|
||||||
|
@ -1098,7 +1098,10 @@ class Device(
|
|||||||
|
|
||||||
:param if_master: If True, return VC member interfaces only if this Device is the VC master.
|
:param if_master: If True, return VC member interfaces only if this Device is the VC master.
|
||||||
"""
|
"""
|
||||||
|
if self.pk:
|
||||||
filter = Q(device=self)
|
filter = Q(device=self)
|
||||||
|
else:
|
||||||
|
filter = Q()
|
||||||
if self.virtual_chassis and (self.virtual_chassis.master == self or not if_master):
|
if self.virtual_chassis and (self.virtual_chassis.master == self or not if_master):
|
||||||
filter |= Q(device__virtual_chassis=self.virtual_chassis, mgmt_only=False)
|
filter |= Q(device__virtual_chassis=self.virtual_chassis, mgmt_only=False)
|
||||||
return Interface.objects.filter(filter)
|
return Interface.objects.filter(filter)
|
||||||
|
@ -182,7 +182,7 @@ class ConfigContextModel(models.Model):
|
|||||||
|
|
||||||
if not hasattr(self, 'config_context_data'):
|
if not hasattr(self, 'config_context_data'):
|
||||||
# The annotation is not available, so we fall back to manually querying for the config context objects
|
# The annotation is not available, so we fall back to manually querying for the config context objects
|
||||||
config_context_data = ConfigContext.objects.get_for_object(self, aggregate_data=True)
|
config_context_data = ConfigContext.objects.get_for_object(self, aggregate_data=True) or []
|
||||||
else:
|
else:
|
||||||
# The attribute may exist, but the annotated value could be None if there is no config context data
|
# The attribute may exist, but the annotated value could be None if there is no config context data
|
||||||
config_context_data = self.config_context_data or []
|
config_context_data = self.config_context_data or []
|
||||||
|
Loading…
Reference in New Issue
Block a user