only sync DataStorages

This commit is contained in:
Cayo Puigdefabregas 2023-02-10 20:09:22 +01:00
parent 2553a9cdd0
commit 77c8e2181f
2 changed files with 11 additions and 10 deletions

View File

@ -16,19 +16,20 @@ from ereuse_devicehub.resources.action.models import Remove
from ereuse_devicehub.resources.device.models import ( from ereuse_devicehub.resources.device.models import (
Component, Component,
Computer, Computer,
DataStorage,
Device, Device,
Placeholder, Placeholder,
) )
from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.tag.model import Tag
DEVICES_ALLOW_DUPLICITY = [ # DEVICES_ALLOW_DUPLICITY = [
'RamModule', # 'RamModule',
'Display', # 'Display',
'SoundCard', # 'SoundCard',
'Battery', # 'Battery',
'Camera', # 'Camera',
'GraphicCard', # 'GraphicCard',
] # ]
class Sync: class Sync:
@ -119,7 +120,7 @@ class Sync:
""" """
assert inspect(component).transient, 'Component should not be synced from DB' assert inspect(component).transient, 'Component should not be synced from DB'
# if not is a DataStorage, then need build a new one # if not is a DataStorage, then need build a new one
if component.t in DEVICES_ALLOW_DUPLICITY: if not isinstance(component, DataStorage):
db.session.add(component) db.session.add(component)
is_new = True is_new = True
return component, is_new return component, is_new

View File

@ -2941,7 +2941,7 @@ def test_delete_devices_check_sync(user: UserClient):
in [y.device.id for y in x.actions if hasattr(y, 'device')] in [y.device.id for y in x.actions if hasattr(y, 'device')]
] ]
) )
== 2 == 0
) )