From 5ae61d30bc4042cef33ba4f5de08a64a500c63c4 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 20 Jan 2021 10:39:02 +0100 Subject: [PATCH] adding systemId in metrics csv --- ereuse_devicehub/resources/device/models.py | 2 ++ ereuse_devicehub/resources/documents/device_row.py | 9 +++++---- tests/test_documents.py | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 3737fe68..a91beb5f 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -335,6 +335,7 @@ class Device(Thing): if act.type == 'Allocate': allo = {'type': 'Allocate', + 'systemId': self.id, 'finalUserCode': act.final_user_code, 'numEndUsers': act.end_users, 'hid': self.hid, @@ -353,6 +354,7 @@ class Device(Thing): if act.type == 'Deallocate': deallo = {'type': 'Deallocate', + 'systemId': self.id, 'finalUserCode': '', 'numEndUsers': '', 'hid': self.hid, diff --git a/ereuse_devicehub/resources/documents/device_row.py b/ereuse_devicehub/resources/documents/device_row.py index 7e5da1b4..5744bbc7 100644 --- a/ereuse_devicehub/resources/documents/device_row.py +++ b/ereuse_devicehub/resources/documents/device_row.py @@ -368,11 +368,12 @@ class ActionRow(OrderedDict): def __init__(self, allocate): super().__init__() # General information about allocates, deallocate and lives + self['SystemId'] = allocate['systemId'] self['Hid'] = allocate['hid'] self['Start'] = allocate['start'] - self['finalUserCode'] = allocate['finalUserCode'] - self['numEndUsers'] = allocate['numEndUsers'] - self['usageTimeAllocate'] = allocate['usageTimeAllocate'] + self['FinalUserCode'] = allocate['finalUserCode'] + self['NumEndUsers'] = allocate['numEndUsers'] + self['UsageTimeAllocate'] = allocate['usageTimeAllocate'] self['Type'] = allocate['type'] self['LiveCreate'] = allocate['liveCreate'] - self['usageTimeHdd'] = allocate['usageTimeHdd'] + self['UsageTimeHdd'] = allocate['usageTimeHdd'] diff --git a/tests/test_documents.py b/tests/test_documents.py index 8b79354c..dee1bd1b 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -173,6 +173,7 @@ def test_live_export_csv2(user: UserClient, client: Client, app: Devicehub): assert "4692" in csv_user assert "8692" in csv_user + assert "SystemId" in csv_user @pytest.mark.mvp @pytest.mark.usefixtures(conftest.app_context.__name__)