adding property power_on_hours

This commit is contained in:
Cayo Puigdefabregas 2021-11-23 15:27:16 +01:00
parent fd57c794e0
commit c4a2b720ef
8 changed files with 43 additions and 9 deletions

View File

@ -17,6 +17,7 @@ ml).
- [added] #167 new actions of status devices: use, recycling, refurbish and management.
- [changes] #177 new structure of trade.
- [bugfix] #184 clean nested of schemas of lot
- [added] #182 adding power on hours
## [1.0.9-beta]
- [added] #159 external document as proof of erase of disk

View File

@ -824,6 +824,12 @@ class TestDataStorage(TestMixin, Test):
def reported_uncorrectable_errors(self):
return self._reported_uncorrectable_errors
@property
def power_on_hours(self):
if not self.lifetime:
return 0
return int(self.lifetime.total_seconds()/3600)
@reported_uncorrectable_errors.setter
def reported_uncorrectable_errors(self, value):
# We assume that a huge number is not meaningful

View File

@ -238,6 +238,7 @@ class TestDataStorage(Test):
length = EnumField(TestDataStorageLength, required=True)
status = SanitizedStr(lower=True, validate=Length(max=STR_SIZE), required=True)
lifetime = TimeDelta(precision=TimeDelta.HOURS)
power_on_hours = Integer(data_key='powerOnHours', dump_only=True)
assessment = Boolean()
reallocated_sector_count = Integer(data_key='reallocatedSectorCount')
power_cycle_count = Integer(data_key='powerCycleCount')

View File

@ -235,6 +235,7 @@ class DeviceRow(OrderedDict):
self['Test {} {} Power on (hours used)'.format(ctype, i)] = ''
self['Test {} {} Lifetime remaining (percentage)'.format(
ctype, i)] = ''
self['Test {} {} Power on hours'.format(ctype, i)] = ''
return
snapshot = get_action(component, 'Snapshot')
@ -332,6 +333,7 @@ class DeviceRow(OrderedDict):
self['Test {} {} Power on (hours used)'.format(ctype, i)] = ''
self['Test {} {} Lifetime remaining (percentage)'.format(
ctype, i)] = ''
self['Test {} {} Power on hours'.format(ctype, i)] = ''
return
self['Test {} {} Software'.format(ctype, i)] = software
@ -342,6 +344,8 @@ class DeviceRow(OrderedDict):
test_storage.power_cycle_count)
self['Test {} {} Lifetime remaining (percentage)'.format(ctype, i)] = none2str(
test_storage.lifetime)
self['Test {} {} Power on hours'.format(ctype, i)] = none2str(
test_storage.power_on_hours)
def get_graphic_card(self, ctype, i, component):
"""Particular fields for component GraphicCard."""

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -301,10 +301,10 @@ def test_export_extended(app: Devicehub, user: UserClient):
assert fixture_csv[2][22:82] == export_csv[2][22:82], 'Computer information are not equal'
assert fixture_csv[2][83] == export_csv[2][83], 'Computer information are not equal'
assert fixture_csv[2][86:106] == export_csv[2][86:106], 'Computer information are not equal'
assert fixture_csv[2][108] == export_csv[2][108], 'Computer information are not equal'
assert fixture_csv[2][111:131] == export_csv[2][111:131], 'Computer information are not equal'
assert fixture_csv[2][131] == export_csv[2][131], 'Computer information are not equal'
assert fixture_csv[2][136:] == export_csv[2][136:], 'Computer information are not equal'
assert fixture_csv[2][109] == export_csv[2][109], 'Computer information are not equal'
assert fixture_csv[2][112:133] == export_csv[2][112:133], 'Computer information are not equal'
assert fixture_csv[2][135] == export_csv[2][135], 'Computer information are not equal'
assert fixture_csv[2][138:] == export_csv[2][138:], 'Computer information are not equal'
@pytest.mark.mvp

View File

@ -146,6 +146,28 @@ def test_snapshot_update_timefield_updated(user: UserClient):
assert pc1['updated'] != snapshot['device']['updated']
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_snapshot_power_on_hours(user: UserClient):
"""
Tests for check if one computer have the time mark updated when one component of it is updated
"""
snap, _ = user.post(file('asus-eee-1000h.snapshot.bug1857'), res=Snapshot)
device = m.Device.query.filter_by(id=snap['device']['id']).one()
for c in device.components:
if c.type == 'HardDrive':
hdd = c
break
for ac in hdd.actions:
if ac.type == 'TestDataStorage':
test_data_storage = ac
break
assert test_data_storage.lifetime.total_seconds()/3600 == test_data_storage.power_on_hours
@pytest.mark.mvp
def test_snapshot_component_add_remove(user: UserClient):
"""Tests adding and removing components and some don't generate HID.