Merge branch 'testing' of github.com:eReuse/devicehub-teal into testing

This commit is contained in:
Cayo Puigdefabregas 2021-11-24 13:24:00 +01:00
commit 7320df3eb2
7 changed files with 48 additions and 17 deletions

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

@ -232,9 +232,9 @@ class DeviceRow(OrderedDict):
self['Test {} {} Software'.format(ctype, i)] = ''
self['Test {} {} Type'.format(ctype, i)] = ''
self['Test {} {} Result'.format(ctype, i)] = ''
self['Test {} {} Power on (hours used)'.format(ctype, i)] = ''
self['Test {} {} Lifetime remaining (percentage)'.format(
ctype, i)] = ''
self['Test {} {} Power cycle count'.format(ctype, i)] = ''
self['Test {} {} Lifetime (days)'.format(ctype, i)] = ''
self['Test {} {} Power on hours'.format(ctype, i)] = ''
return
snapshot = get_action(component, 'Snapshot')
@ -329,19 +329,21 @@ class DeviceRow(OrderedDict):
self['Test {} {} Software'.format(ctype, i)] = ''
self['Test {} {} Type'.format(ctype, i)] = ''
self['Test {} {} Result'.format(ctype, i)] = ''
self['Test {} {} Power on (hours used)'.format(ctype, i)] = ''
self['Test {} {} Lifetime remaining (percentage)'.format(
ctype, i)] = ''
self['Test {} {} Power cycle count'.format(ctype, i)] = ''
self['Test {} {} Lifetime (days)'.format(ctype, i)] = ''
self['Test {} {} Power on hours'.format(ctype, i)] = ''
return
self['Test {} {} Software'.format(ctype, i)] = software
self['Test {} {} Type'.format(ctype, i)] = test_storage.length.value
self['Test {} {} Result'.format(ctype, i)] = get_result(
test_storage)
self['Test {} {} Power on (hours used)'.format(ctype, i)] = none2str(
self['Test {} {} Power cycle count'.format(ctype, i)] = none2str(
test_storage.power_cycle_count)
self['Test {} {} Lifetime remaining (percentage)'.format(ctype, i)] = none2str(
self['Test {} {} Lifetime (days)'.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.