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 (
Component,
Computer,
DataStorage,
Device,
Placeholder,
)
from ereuse_devicehub.resources.tag.model import Tag
DEVICES_ALLOW_DUPLICITY = [
'RamModule',
'Display',
'SoundCard',
'Battery',
'Camera',
'GraphicCard',
]
# DEVICES_ALLOW_DUPLICITY = [
# 'RamModule',
# 'Display',
# 'SoundCard',
# 'Battery',
# 'Camera',
# 'GraphicCard',
# ]
class Sync:
@ -119,7 +120,7 @@ class Sync:
"""
assert inspect(component).transient, 'Component should not be synced from DB'
# 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)
is_new = True
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')]
]
)
== 2
== 0
)