diff --git a/ereuse_devicehub/resources/device/sync.py b/ereuse_devicehub/resources/device/sync.py index 4871d6b7..952e935b 100644 --- a/ereuse_devicehub/resources/device/sync.py +++ b/ereuse_devicehub/resources/device/sync.py @@ -197,6 +197,7 @@ class Sync: ).one() if db_device and db_device.allocated: raise ResourceNotFound('device is actually allocated {}'.format(device)) + try: tags = { Tag.from_an_id(tag.id).one() for tag in device.tags @@ -264,6 +265,13 @@ class Sync: if value is not None: setattr(db_device, field_name, value) + # if device.system_uuid and db_device.system_uuid and device.system_uuid != db_device.system_uuid: + # TODO @cayop send error to sentry.io + # there are 2 computers duplicate get db_device for hid + + if hasattr(device, 'system_uuid') and device.system_uuid: + db_device.system_uuid = device.system_uuid + @staticmethod def add_remove(device: Computer, components: Set[Component]) -> OrderedSet: """Generates the Add and Remove actions (but doesn't add them to diff --git a/tests/test_system_uuid.py b/tests/test_system_uuid.py index 6be21dc4..e8f62956 100644 --- a/tests/test_system_uuid.py +++ b/tests/test_system_uuid.py @@ -102,6 +102,10 @@ def test_wb11_to_wb11_with_uuid_api(user: UserClient): snapshot_11['uuid'] = '0973fda0-589a-11eb-ae93-0242ac130003' user.post(snapshot_11, res=Snapshot) + assert ( + snapshot_11['debug']['lshw']['configuration']['uuid'] + == '364ee69c-9c82-9cb1-2111-88ae1da6f3d0' + ) assert Computer.query.count() == 1 device = Computer.query.one() assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'