test: Ensure service fixture assosiates with device

ref: #833 #828
This commit is contained in:
2025-06-16 16:22:07 +09:30
parent e3804b4f9b
commit 0b8b0bc850

View File

@ -12,15 +12,31 @@ def model_service():
@pytest.fixture( scope = 'class') @pytest.fixture( scope = 'class')
def kwargs_service(kwargs_centurionmodel): def kwargs_service(django_db_blocker,
kwargs_centurionmodel,
kwargs_device, model_device
):
random_str = str(datetime.datetime.now(tz=datetime.timezone.utc)) random_str = str(datetime.datetime.now(tz=datetime.timezone.utc))
random_str = str(random_str).replace( random_str = str(random_str).replace(
' ', '').replace(':', '').replace('+', '').replace('.', '') ' ', '').replace(':', '').replace('+', '').replace('.', '')
with django_db_blocker.unblock():
kwargs = kwargs_device.copy()
kwargs.update({
'name': 'svc' + random_str
})
device = model_device.objects.create( **kwargs )
kwargs = { kwargs = {
**kwargs_centurionmodel.copy(), **kwargs_centurionmodel.copy(),
'name': 'service_' + random_str, 'name': 'service_' + random_str,
} }
yield kwargs.copy() yield kwargs.copy()
with django_db_blocker.unblock():
device.delete()