refactor: cater for dev that does not exist in test cleanup

ref: #823
This commit is contained in:
2025-06-12 11:55:13 +09:30
parent 7542521866
commit ecc544ce19
2 changed files with 24 additions and 4 deletions

View File

@ -1,6 +1,8 @@
import datetime
import pytest
from django.core.exceptions import ObjectDoesNotExist
from itam.models.device import DeviceOperatingSystem
@ -24,12 +26,22 @@ def kwargs_deviceoperatingsystem(django_db_blocker,
with django_db_blocker.unblock():
kwargs = kwargs_device.copy()
kwargs.update({
'name': 'dos' + random_str
})
device = model_device.objects.create(
**kwargs_device.copy()
**kwargs
)
kwargs = kwargs_operatingsystemversion.copy()
kwargs.update({
'name': 'dos' + random_str
})
operating_system_version = model_operatingsystemversion.objects.create(
**kwargs_operatingsystemversion.copy()
**kwargs
)
kwargs = {
@ -44,6 +56,9 @@ def kwargs_deviceoperatingsystem(django_db_blocker,
with django_db_blocker.unblock():
device.delete()
try:
device.delete()
except ObjectDoesNotExist:
pass
operating_system_version.delete()

View File

@ -1,6 +1,8 @@
import datetime
import pytest
from django.core.exceptions import ObjectDoesNotExist
from itam.models.device import DeviceSoftware
@ -46,6 +48,9 @@ def kwargs_devicesoftware(django_db_blocker,
with django_db_blocker.unblock():
device.delete()
try:
device.delete()
except ObjectDoesNotExist:
pass
softwareversion.delete()