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): def reported_uncorrectable_errors(self):
return self._reported_uncorrectable_errors 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 @reported_uncorrectable_errors.setter
def reported_uncorrectable_errors(self, value): def reported_uncorrectable_errors(self, value):
# We assume that a huge number is not meaningful # We assume that a huge number is not meaningful

View file

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

View file

@ -232,9 +232,9 @@ class DeviceRow(OrderedDict):
self['Test {} {} Software'.format(ctype, i)] = '' self['Test {} {} Software'.format(ctype, i)] = ''
self['Test {} {} Type'.format(ctype, i)] = '' self['Test {} {} Type'.format(ctype, i)] = ''
self['Test {} {} Result'.format(ctype, i)] = '' self['Test {} {} Result'.format(ctype, i)] = ''
self['Test {} {} Power on (hours used)'.format(ctype, i)] = '' self['Test {} {} Power cycle count'.format(ctype, i)] = ''
self['Test {} {} Lifetime remaining (percentage)'.format( self['Test {} {} Lifetime (days)'.format(ctype, i)] = ''
ctype, i)] = '' self['Test {} {} Power on hours'.format(ctype, i)] = ''
return return
snapshot = get_action(component, 'Snapshot') snapshot = get_action(component, 'Snapshot')
@ -329,19 +329,21 @@ class DeviceRow(OrderedDict):
self['Test {} {} Software'.format(ctype, i)] = '' self['Test {} {} Software'.format(ctype, i)] = ''
self['Test {} {} Type'.format(ctype, i)] = '' self['Test {} {} Type'.format(ctype, i)] = ''
self['Test {} {} Result'.format(ctype, i)] = '' self['Test {} {} Result'.format(ctype, i)] = ''
self['Test {} {} Power on (hours used)'.format(ctype, i)] = '' self['Test {} {} Power cycle count'.format(ctype, i)] = ''
self['Test {} {} Lifetime remaining (percentage)'.format( self['Test {} {} Lifetime (days)'.format(ctype, i)] = ''
ctype, i)] = '' self['Test {} {} Power on hours'.format(ctype, i)] = ''
return return
self['Test {} {} Software'.format(ctype, i)] = software self['Test {} {} Software'.format(ctype, i)] = software
self['Test {} {} Type'.format(ctype, i)] = test_storage.length.value self['Test {} {} Type'.format(ctype, i)] = test_storage.length.value
self['Test {} {} Result'.format(ctype, i)] = get_result( self['Test {} {} Result'.format(ctype, i)] = get_result(
test_storage) 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) 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) 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): def get_graphic_card(self, ctype, i, component):
"""Particular fields for component GraphicCard.""" """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][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][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][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][109] == export_csv[2][109], '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][112:133] == export_csv[2][112:133], 'Computer information are not equal'
assert fixture_csv[2][131] == export_csv[2][131], 'Computer information are not equal' assert fixture_csv[2][135] == export_csv[2][135], 'Computer information are not equal'
assert fixture_csv[2][136:] == export_csv[2][136:], 'Computer information are not equal' assert fixture_csv[2][138:] == export_csv[2][138:], 'Computer information are not equal'
@pytest.mark.mvp @pytest.mark.mvp

View file

@ -146,6 +146,28 @@ def test_snapshot_update_timefield_updated(user: UserClient):
assert pc1['updated'] != snapshot['device']['updated'] 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 @pytest.mark.mvp
def test_snapshot_component_add_remove(user: UserClient): def test_snapshot_component_add_remove(user: UserClient):
"""Tests adding and removing components and some don't generate HID. """Tests adding and removing components and some don't generate HID.