From 77c8e2181fb7cceb08313907b01ddadc17941eed Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 10 Feb 2023 20:09:22 +0100 Subject: [PATCH] only sync DataStorages --- ereuse_devicehub/resources/device/sync.py | 19 ++++++++++--------- tests/test_action.py | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ereuse_devicehub/resources/device/sync.py b/ereuse_devicehub/resources/device/sync.py index 510e425a..32c4a2f2 100644 --- a/ereuse_devicehub/resources/device/sync.py +++ b/ereuse_devicehub/resources/device/sync.py @@ -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 diff --git a/tests/test_action.py b/tests/test_action.py index 9ccb07a3..01ca8ca6 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -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 )