new endpoint live

This commit is contained in:
Cayo Puigdefabregas 2020-12-28 18:02:47 +01:00
parent 4ffd95c158
commit 676cfe96d8
4 changed files with 2 additions and 10 deletions

View File

@ -1321,7 +1321,6 @@ class Live(JoinedWithOneDeviceMixin, ActionWithOneDevice):
@property @property
def usage_time_allocate(self): def usage_time_allocate(self):
"""Show how many hours is used one device from the last check""" """Show how many hours is used one device from the last check"""
# import pdb; pdb.set_trace()
self.sort_actions() self.sort_actions()
if self.usage_time_hdd is None: if self.usage_time_hdd is None:
return self.last_usage_time_allocate() return self.last_usage_time_allocate()

View File

@ -432,10 +432,6 @@ class Live(ActionWithOneDevice):
description='The software that generated this Snapshot.') description='The software that generated this Snapshot.')
version = Version(required=True, description='The version of the software.') version = Version(required=True, description='The version of the software.')
final_user_code = SanitizedStr(data_key="finalUserCode", dump_only=True) 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.') licence_version = Version(required=True, description='The version of the software.')
components = NestedOn(s_device.Component, components = NestedOn(s_device.Component,
many=True, many=True,
@ -443,7 +439,8 @@ class Live(ActionWithOneDevice):
'at the moment of this Snapshot.' 'at the moment of this Snapshot.'
'Order is preserved, so the component num 0 when' 'Order is preserved, so the component num 0 when'
'submitting is the component num 0 when returning it back.') '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): class Organize(ActionWithMultipleDevices):

View File

@ -121,7 +121,6 @@ class LiveView(View):
"""We get the liftime and serial_number of the disk""" """We get the liftime and serial_number of the disk"""
usage_time_hdd = None usage_time_hdd = None
serial_number = None serial_number = None
import pdb; pdb.set_trace()
for hd in snapshot['components']: for hd in snapshot['components']:
if not isinstance(hd, DataStorage): if not isinstance(hd, DataStorage):
continue continue
@ -175,7 +174,6 @@ class LiveView(View):
if not device.allocated: if not device.allocated:
raise ValidationError('Sorry this device is not 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) usage_time_hdd, serial_number = self.get_hdd_details(snapshot, device)
data_live = {'usage_time_hdd': usage_time_hdd, data_live = {'usage_time_hdd': usage_time_hdd,

View File

@ -454,12 +454,10 @@ def test_live_search_last_allocate(user: UserClient, app: Devicehub):
hdd_action['lifetime'] += 1000 hdd_action['lifetime'] += 1000
acer.pop('elapsed') acer.pop('elapsed')
acer['licence_version'] = '1.0.0' acer['licence_version'] = '1.0.0'
import pdb; pdb.set_trace()
live, _ = user.post(acer, res=models.Live) live, _ = user.post(acer, res=models.Live)
acer['uuid'] = "490fb8c0-81a1-42e9-95e0-5e7db7038ec4" acer['uuid'] = "490fb8c0-81a1-42e9-95e0-5e7db7038ec4"
actions = [a for a in acer['components'][7]['actions'] if a['type'] != 'TestDataStorage'] actions = [a for a in acer['components'][7]['actions'] if a['type'] != 'TestDataStorage']
acer['components'][7]['actions'] = actions acer['components'][7]['actions'] = actions
import pdb; pdb.set_trace()
live, _ = user.post(acer, res=models.Live) live, _ = user.post(acer, res=models.Live)
assert live['usageTimeAllocate'] == 1000 assert live['usageTimeAllocate'] == 1000