From 42c5bee9471e2294b45b70bab3732dc83a7580f6 Mon Sep 17 00:00:00 2001 From: Xavier Bustamante Talavera Date: Sat, 27 Oct 2018 08:56:58 +0200 Subject: [PATCH] Fix benchmark rates not using floats; add oreo and david's pc --- ereuse_devicehub/dummy/dummy.py | 6 +- .../dummy/files/oreo.snapshot.yaml | 2 +- ereuse_devicehub/resources/event/models.py | 4 +- ereuse_devicehub/resources/event/schemas.py | 2 +- tests/files/david.lshw.snapshot.yaml | 128 ++++++++++++++++++ tests/test_workbench.py | 5 + 6 files changed, 140 insertions(+), 7 deletions(-) create mode 100644 tests/files/david.lshw.snapshot.yaml diff --git a/ereuse_devicehub/dummy/dummy.py b/ereuse_devicehub/dummy/dummy.py index 472bd652..04fe7b97 100644 --- a/ereuse_devicehub/dummy/dummy.py +++ b/ereuse_devicehub/dummy/dummy.py @@ -28,7 +28,7 @@ class Dummy: ET = ( ('A0000000000001', 'DT-AAAAA'), ('A0000000000002', 'DT-BBBBB'), - ('A0000000000002', 'DT-CCCCC'), + ('A0000000000003', 'DT-CCCCC'), ) """eTags to create.""" ORG = 'eReuse.org CAT', '-t', 'G-60437761', '-c', 'ES' @@ -119,9 +119,9 @@ class Dummy: assert len(inventory['items']) i, _ = user.get(res=Device, query=[('search', 'intel')]) - assert len(i['items']) == 11 - i, _ = user.get(res=Device, query=[('search', 'pc')]) assert len(i['items']) == 12 + i, _ = user.get(res=Device, query=[('search', 'pc')]) + assert len(i['items']) == 13 # Let's create a set of events for the pc device # Make device Ready diff --git a/ereuse_devicehub/dummy/files/oreo.snapshot.yaml b/ereuse_devicehub/dummy/files/oreo.snapshot.yaml index 4ceeb12d..29443538 100644 --- a/ereuse_devicehub/dummy/files/oreo.snapshot.yaml +++ b/ereuse_devicehub/dummy/files/oreo.snapshot.yaml @@ -154,7 +154,7 @@ } ], "tags": [ - {"id": "A0000000000002", "type": "Tag"} + {"id": "A0000000000003", "type": "Tag"} ] }, "version": "11.0a6", diff --git a/ereuse_devicehub/resources/event/models.py b/ereuse_devicehub/resources/event/models.py index 81edf3fc..f1ba4f8a 100644 --- a/ereuse_devicehub/resources/event/models.py +++ b/ereuse_devicehub/resources/event/models.py @@ -10,7 +10,7 @@ from boltons import urlutils from citext import CIText from flask import current_app as app, g from sqlalchemy import BigInteger, Boolean, CheckConstraint, Column, DateTime, Enum as DBEnum, \ - Float, ForeignKey, Interval, JSON, Numeric, SmallInteger, Unicode, event, orm + Float, ForeignKey, Interval, JSON, Numeric, SmallInteger, Unicode, event, orm, Integer from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.ext.declarative import declared_attr from sqlalchemy.ext.orderinglist import ordering_list @@ -812,7 +812,7 @@ class BenchmarkDataStorage(Benchmark): class BenchmarkWithRate(Benchmark): id = Column(UUID(as_uuid=True), ForeignKey(Benchmark.id), primary_key=True) - rate = Column(SmallInteger, nullable=False) + rate = Column(Float, nullable=False) def __str__(self) -> str: return '{} points'.format(self.rate) diff --git a/ereuse_devicehub/resources/event/schemas.py b/ereuse_devicehub/resources/event/schemas.py index bf3302d7..12a196cf 100644 --- a/ereuse_devicehub/resources/event/schemas.py +++ b/ereuse_devicehub/resources/event/schemas.py @@ -299,7 +299,7 @@ class BenchmarkDataStorage(Benchmark): class BenchmarkWithRate(Benchmark): - rate = Integer(required=True) + rate = Float(required=True) class BenchmarkProcessor(BenchmarkWithRate): diff --git a/tests/files/david.lshw.snapshot.yaml b/tests/files/david.lshw.snapshot.yaml new file mode 100644 index 00000000..7cd76152 --- /dev/null +++ b/tests/files/david.lshw.snapshot.yaml @@ -0,0 +1,128 @@ +{ + "type": "Snapshot", + "uuid": "00000000-0000-0000-0000-000000000000", + "software": "Workbench", + "version": "11.0a1", + "expectedEvents": [], + "closed": true, + "endTime": "0001-01-01 00:00:00", + "device": { + "manufacturer": "Dell Inc.", + "model": "Latitude E6440", + "serialNumber": "FJBQVZ1", + "events": [], + "type": "Laptop", + "chassis": "Laptop" + }, + "components": [ + { + "manufacturer": "Intel Corp.", + "model": "Intel Core i7-4600M CPU @ 2.90GHz", + "serialNumber": null, + "events": [], + "type": "Processor", + "speed": 1.259899, + "address": 64, + "cores": 2, + "threads": 4 + }, + { + "manufacturer": "Samsung", + "model": "M471B5173DB0-YK0", + "serialNumber": "732CD498", + "events": [], + "type": "RamModule", + "format": "SODIMM", + "size": 4096, + "interface": "DDR3", + "speed": 1600.0 + }, + { + "manufacturer": "Samsung", + "model": "M471B5173DB0-YK0", + "serialNumber": "152DD498", + "events": [], + "type": "RamModule", + "format": "SODIMM", + "size": 4096, + "interface": "DDR3", + "speed": 1600.0 + }, + { + "manufacturer": null, + "model": "Crucial_CT525MX3", + "serialNumber": "164014297BCC", + "events": [], + "type": "HardDrive", + "size": 500786, + "interface": null + }, + { + "manufacturer": "Intel Corporation", + "model": "4th Gen Core Processor Integrated Graphics Controller", + "serialNumber": null, + "events": [], + "type": "GraphicCard", + "memory": null + }, + { + "manufacturer": "Intel Corporation", + "model": "Ethernet Connection I217-LM", + "serialNumber": "ec:f4:bb:0b:18:90", + "events": [], + "type": "NetworkAdapter", + "speed": 1000, + "wireless": false + }, + { + "manufacturer": "Intel Corporation", + "model": "Centrino Advanced-N 6235", + "serialNumber": "c4:d9:87:47:90:e1", + "events": [], + "type": "NetworkAdapter", + "wireless": true + }, + { + "manufacturer": null, + "model": null, + "serialNumber": "da:b4:3a:25:88:6c", + "events": [], + "type": "NetworkAdapter", + "wireless": false + }, + { + "manufacturer": "Intel Corporation", + "model": "Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller", + "serialNumber": null, + "events": [], + "type": "SoundCard" + }, + { + "manufacturer": "CNFCH52J48303+YF2", + "model": "Laptop_Integrated_Webcam_HD", + "serialNumber": null, + "events": [], + "type": "SoundCard" + }, + { + "manufacturer": "Intel Corporation", + "model": "8 Series/C220 Series Chipset High Definition Audio Controller", + "serialNumber": null, + "events": [], + "type": "SoundCard" + }, + { + "manufacturer": "Dell Inc.", + "model": "0159N7", + "serialNumber": "/FJBQVZ1/CN1296342I009B/", + "events": [], + "type": "Motherboard", + "usb": 3, + "firewire": 0, + "serial": 1, + "pcmcia": 0, + "slots": 1 + } + ], + "elapsed": 0 +} \ No newline at end of file diff --git a/tests/test_workbench.py b/tests/test_workbench.py index 1b1b7f2a..22b57685 100644 --- a/tests/test_workbench.py +++ b/tests/test_workbench.py @@ -320,3 +320,8 @@ def test_workbench_asus_1001pxd_rate_low(user: UserClient): """Tests an Asus 1001pxd with a low rate.""" s = file('asus-1001pxd.snapshot') snapshot, _ = user.post(res=em.Snapshot, data=s) + + +def test_david(user: UserClient): + s = file('david.lshw.snapshot') + snapshot, _ = user.post(res=em.Snapshot, data=s)