From 676cfe96d8e069474101f1e8b25538811dae261d Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 28 Dec 2020 18:02:47 +0100 Subject: [PATCH] new endpoint live --- ereuse_devicehub/resources/action/models.py | 1 - ereuse_devicehub/resources/action/schemas.py | 7 ++----- ereuse_devicehub/resources/action/views.py | 2 -- tests/test_action.py | 2 -- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/ereuse_devicehub/resources/action/models.py b/ereuse_devicehub/resources/action/models.py index e4f0a513..af5f1047 100644 --- a/ereuse_devicehub/resources/action/models.py +++ b/ereuse_devicehub/resources/action/models.py @@ -1321,7 +1321,6 @@ class Live(JoinedWithOneDeviceMixin, ActionWithOneDevice): @property def usage_time_allocate(self): """Show how many hours is used one device from the last check""" - # import pdb; pdb.set_trace() self.sort_actions() if self.usage_time_hdd is None: return self.last_usage_time_allocate() diff --git a/ereuse_devicehub/resources/action/schemas.py b/ereuse_devicehub/resources/action/schemas.py index baa8828e..fcc3e767 100644 --- a/ereuse_devicehub/resources/action/schemas.py +++ b/ereuse_devicehub/resources/action/schemas.py @@ -432,10 +432,6 @@ class Live(ActionWithOneDevice): description='The software that generated this Snapshot.') version = Version(required=True, description='The version of the software.') final_user_code = SanitizedStr(data_key="finalUserCode", dump_only=True) - software = EnumField(SnapshotSoftware, - required=True, - description='The software that generated this Snapshot.') - version = Version(required=True, description='The version of the software.') licence_version = Version(required=True, description='The version of the software.') components = NestedOn(s_device.Component, many=True, @@ -443,7 +439,8 @@ class Live(ActionWithOneDevice): 'at the moment of this Snapshot.' 'Order is preserved, so the component num 0 when' 'submitting is the component num 0 when returning it back.') - usage_time_allocate = TimeDelta(data_key='usageTimeAllocate', required=False,) + usage_time_allocate = TimeDelta(data_key='usageTimeAllocate', required=False, + precision=TimeDelta.HOURS, dump_only=True) class Organize(ActionWithMultipleDevices): diff --git a/ereuse_devicehub/resources/action/views.py b/ereuse_devicehub/resources/action/views.py index 287f91ec..ceecf6fe 100644 --- a/ereuse_devicehub/resources/action/views.py +++ b/ereuse_devicehub/resources/action/views.py @@ -121,7 +121,6 @@ class LiveView(View): """We get the liftime and serial_number of the disk""" usage_time_hdd = None serial_number = None - import pdb; pdb.set_trace() for hd in snapshot['components']: if not isinstance(hd, DataStorage): continue @@ -175,7 +174,6 @@ class LiveView(View): if not device.allocated: raise ValidationError('Sorry this device is not allocated.') - import pdb; pdb.set_trace() usage_time_hdd, serial_number = self.get_hdd_details(snapshot, device) data_live = {'usage_time_hdd': usage_time_hdd, diff --git a/tests/test_action.py b/tests/test_action.py index 34b42670..314257b3 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -454,12 +454,10 @@ def test_live_search_last_allocate(user: UserClient, app: Devicehub): hdd_action['lifetime'] += 1000 acer.pop('elapsed') acer['licence_version'] = '1.0.0' - import pdb; pdb.set_trace() live, _ = user.post(acer, res=models.Live) acer['uuid'] = "490fb8c0-81a1-42e9-95e0-5e7db7038ec4" actions = [a for a in acer['components'][7]['actions'] if a['type'] != 'TestDataStorage'] acer['components'][7]['actions'] = actions - import pdb; pdb.set_trace() live, _ = user.post(acer, res=models.Live) assert live['usageTimeAllocate'] == 1000