From 33f6ee540bbee1b96726359c4915a69393be9aeb Mon Sep 17 00:00:00 2001 From: Xavier Bustamante Talavera Date: Mon, 26 Nov 2018 13:11:07 +0100 Subject: [PATCH] Add Install.address; fix asus test --- ereuse_devicehub/dummy/dummy.py | 8 +- .../dummy/files/asus-1001pxd.snapshot.11.yaml | 190 ++++++++++++++++++ ereuse_devicehub/resources/event/models.py | 1 + ereuse_devicehub/resources/event/models.pyi | 6 +- ereuse_devicehub/resources/event/schemas.py | 3 +- 5 files changed, 203 insertions(+), 5 deletions(-) create mode 100644 ereuse_devicehub/dummy/files/asus-1001pxd.snapshot.11.yaml diff --git a/ereuse_devicehub/dummy/dummy.py b/ereuse_devicehub/dummy/dummy.py index fee2da66..2a072c3f 100644 --- a/ereuse_devicehub/dummy/dummy.py +++ b/ereuse_devicehub/dummy/dummy.py @@ -29,7 +29,8 @@ class Dummy: ('A0000000000001', 'DT-AAAAA'), ('A0000000000002', 'DT-BBBBB'), ('A0000000000003', 'DT-CCCCC'), - ('04970DA2A15984', 'DT-BRRAB') + ('04970DA2A15984', 'DT-BRRAB'), + ('04e4bc5af95980', 'DT-XXXXX') ) """eTags to create.""" ORG = 'eReuse.org CAT', '-t', 'G-60437761', '-c', 'ES' @@ -81,10 +82,11 @@ class Dummy: sample_pc = s['device']['id'] else: pcs.add(s['device']['id']) - if s.get('uuid', None) == 'de4f495e-c58b-40e1-a33e-46ab5e84767e': # oreo + if s.get('uuid', None) == 'de4f495e-c58b-40e1-a33e-46ab5e84767e': # oreo # Make one hdd ErasePhysical hdd = next(hdd for hdd in s['components'] if hdd['type'] == 'HardDrive') - user.post({'type': 'ErasePhysical', 'method': 'Shred', 'device': hdd['id']}, res=m.Event) + user.post({'type': 'ErasePhysical', 'method': 'Shred', 'device': hdd['id']}, + res=m.Event) assert sample_pc print('PC sample is', sample_pc) # Link tags and eTags diff --git a/ereuse_devicehub/dummy/files/asus-1001pxd.snapshot.11.yaml b/ereuse_devicehub/dummy/files/asus-1001pxd.snapshot.11.yaml new file mode 100644 index 00000000..bce2934c --- /dev/null +++ b/ereuse_devicehub/dummy/files/asus-1001pxd.snapshot.11.yaml @@ -0,0 +1,190 @@ +# This is a complete Snapshot with benchmarks, tests, erasure +# installation, and an eTag (TIS) linked +{ + "closed": true, + "components": [ + { + "address": 64, + "cores": 1, + "events": [ + { + "elapsed": 0, + "rate": 6666.22, + "type": "BenchmarkProcessor" + }, + { + "elapsed": 165, + "rate": 165.365, + "type": "BenchmarkProcessorSysbench" + } + ], + "manufacturer": "Intel Corp.", + "model": "Intel Atom CPU N455 @ 1.66GHz", + "serialNumber": null, + "speed": 1.667, + "threads": 2, + "type": "Processor" + }, + { + "events": [], + "manufacturer": "Qualcomm Atheros", + "model": "AR9285 Wireless Network Adapter", + "serialNumber": "74:2f:68:8b:fd:c8", + "type": "NetworkAdapter", + "wireless": true + }, + { + "events": [], + "manufacturer": "Qualcomm Atheros", + "model": "AR8152 v2.0 Fast Ethernet", + "serialNumber": "14:da:e9:42:f6:7c", + "speed": 100, + "type": "NetworkAdapter", + "wireless": false + }, + { + "events": [], + "format": "DIMM", + "interface": "DDR2", + "manufacturer": null, + "model": null, + "serialNumber": null, + "size": 1024, + "speed": 667.0, + "type": "RamModule" + }, + { + "events": [], + "manufacturer": "Intel Corporation", + "model": "NM10/ICH7 Family High Definition Audio Controller", + "serialNumber": null, + "type": "SoundCard" + }, + { + "events": [], + "manufacturer": "Azurewave", + "model": "USB 2.0 UVC VGA WebCam", + "serialNumber": "0x0001", + "type": "SoundCard" + }, + { + "events": [ + { + "endTime": "2018-11-24T22:00:39.643726+00:00", + "severity": "Info", + "startTime": "2018-11-24T18:12:42.641985+00:00", + "steps": [ + { + "endTime": "2018-11-24T19:28:51.215882+00:00", + "severity": "Info", + "startTime": "2018-11-24T18:12:42.643104+00:00", + "type": "StepZero" + }, + { + "endTime": "2018-11-24T22:00:39.642482+00:00", + "severity": "Info", + "startTime": "2018-11-24T19:28:51.216747+00:00", + "type": "StepRandom" + } + ], + "type": "EraseSectors" + }, + { + "assessment": true, + "currentPendingSectorCount": 0, + "elapsed": 99, + "length": "Short", + "lifetime": 1199, + "offlineUncorrectable": 0, + "powerCycleCount": 2128, + "reallocatedSectorCount": 0, + "severity": "Info", + "status": "Completed without error", + "type": "TestDataStorage" + }, + { + "type": "Install", + "elapsed": 1000, + "name": "LinuxMintFSAx32-Eng.fsa", + "address": 32 + }, + { + "elapsed": 16, + "readSpeed": 66.1, + "type": "BenchmarkDataStorage", + "writeSpeed": 21.8 + } + ], + "interface": "ATA", + "manufacturer": "Hitachi", + "model": "HTS54322", + "serialNumber": "E2024242CV86HJ", + "size": 238475, + "type": "HardDrive" + }, + { + "events": [], + "manufacturer": "Intel Corporation", + "memory": 256.0, + "model": "Atom Processor D4xx/D5xx/N4xx/N5xx Integrated Graphics Controller", + "serialNumber": null, + "type": "GraphicCard" + }, + { + "events": [], + "firewire": 0, + "manufacturer": "ASUSTeK Computer INC.", + "model": "1001PXD", + "pcmcia": 0, + "serial": 1, + "serialNumber": "Eee0123456789", + "slots": 2, + "type": "Motherboard", + "usb": 5 + } + ], + "device": { + "chassis": "Netbook", + "events": [ + { + "elapsed": 16, + "rate": 15.9165, + "type": "BenchmarkRamSysbench" + }, + { + "elapsed": 60, + "severity": "Info", + "type": "StressTest" + }, + { + "appearanceRange": "A", + "biosRange": "A", + "functionalityRange": "A", + "type": "WorkbenchRate" + } + ], + "manufacturer": "ASUSTeK Computer INC.", + "model": "1001PXD", + "serialNumber": "B8OAAS048286", + "tags": [ + { + "id": "04e4bc5af95980", + "type": "Tag" + } + ], + "type": "Laptop" + }, + "elapsed": 14725, + "endTime": "2018-11-24T18:06:37.611704+00:00", + "expectedEvents": [ + "Benchmark", + "TestDataStorage", + "StressTest", + "EraseBasic", + "Install" + ], + "software": "Workbench", + "type": "Snapshot", + "uuid": "f6cba71f-0ac1-4aba-8b6a-c1fd56ab483d", + "version": "11.0b2" +} diff --git a/ereuse_devicehub/resources/event/models.py b/ereuse_devicehub/resources/event/models.py index 14949664..f15ed1b2 100644 --- a/ereuse_devicehub/resources/event/models.py +++ b/ereuse_devicehub/resources/event/models.py @@ -521,6 +521,7 @@ class Install(JoinedWithOneDeviceMixin, EventWithOneDevice): storage unit. """ elapsed = Column(Interval, nullable=False) + address = Column(SmallInteger, check_range('address', 8, 256)) class SnapshotRequest(db.Model): diff --git a/ereuse_devicehub/resources/event/models.pyi b/ereuse_devicehub/resources/event/models.pyi index b5d69a89..69971700 100644 --- a/ereuse_devicehub/resources/event/models.pyi +++ b/ereuse_devicehub/resources/event/models.pyi @@ -124,11 +124,15 @@ class Snapshot(EventWithOneDevice): class Install(EventWithOneDevice): + name = ... # type: Column + elapsed = ... # type: Column + address = ... # type: Column + def __init__(self, **kwargs) -> None: super().__init__(**kwargs) self.name = ... # type: str self.elapsed = ... # type: timedelta - self.success = ... # type: bool + self.address = ... # type: Optional[int] class SnapshotRequest(Model): diff --git a/ereuse_devicehub/resources/event/schemas.py b/ereuse_devicehub/resources/event/schemas.py index 1b2ade28..b32f2dec 100644 --- a/ereuse_devicehub/resources/event/schemas.py +++ b/ereuse_devicehub/resources/event/schemas.py @@ -2,7 +2,7 @@ from flask import current_app as app from marshmallow import Schema as MarshmallowSchema, ValidationError, fields as f, validates_schema from marshmallow.fields import Boolean, DateTime, Decimal, Float, Integer, List, Nested, String, \ TimeDelta, UUID -from marshmallow.validate import Length, Range +from marshmallow.validate import Length, OneOf, Range from sqlalchemy.util import OrderedSet from teal.enums import Country, Currency, Subdivision from teal.marshmallow import EnumField, IP, SanitizedStr, URL, Version @@ -205,6 +205,7 @@ class Install(EventWithOneDevice): required=True, description='The name of the OS installed.') elapsed = TimeDelta(precision=TimeDelta.SECONDS, required=True) + address = Integer(validate=OneOf({8, 16, 32, 64, 128, 256})) class Snapshot(EventWithOneDevice):