From f148a42da1db9f6da1b650299f7947ff26413284 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 3 Mar 2021 10:39:40 +0100 Subject: [PATCH 01/16] base of migration --- .../8cb91ad1cc40_add_code_to_device.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py diff --git a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py new file mode 100644 index 00000000..bf49f056 --- /dev/null +++ b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py @@ -0,0 +1,33 @@ +"""add code to device + +Revision ID: 8cb91ad1cc40 +Revises: eca457d8b2a4 +Create Date: 2021-03-03 10:39:19.331027 + +""" +from alembic import op +import sqlalchemy as sa +import sqlalchemy_utils +import citext +import teal + + +# revision identifiers, used by Alembic. +revision = '8cb91ad1cc40' +down_revision = 'eca457d8b2a4' +branch_labels = None +depends_on = None + + +def get_inv(): + INV = context.get_x_argument(as_dictionary=True).get('inventory') + if not INV: + raise ValueError("Inventory value is not specified") + return INV + +def upgrade(): + pass + + +def downgrade(): + pass From e58b08e12c16c97d0c01e068ba9a665f70db2b92 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 3 Mar 2021 20:04:57 +0100 Subject: [PATCH 02/16] add code in migrations --- .../versions/8cb91ad1cc40_add_code_to_device.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py index bf49f056..44d7c39a 100644 --- a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py +++ b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py @@ -6,10 +6,9 @@ Create Date: 2021-03-03 10:39:19.331027 """ from alembic import op +from alembic import context import sqlalchemy as sa -import sqlalchemy_utils import citext -import teal # revision identifiers, used by Alembic. @@ -25,9 +24,11 @@ def get_inv(): raise ValueError("Inventory value is not specified") return INV + def upgrade(): - pass + op.add_column('device', sa.Column('code', citext.CIText(), + nullable=True), schema=f'{get_inv()}') def downgrade(): - pass + op.drop_column('device', 'code', schema=f'{get_inv()}') From 269550270f7a16c1f67595132f8470cb177caa0a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 3 Mar 2021 20:05:48 +0100 Subject: [PATCH 03/16] add code in device and add listener --- ereuse_devicehub/resources/device/models.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 8386b2ba..f9c7db13 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -8,6 +8,7 @@ from typing import Dict, List, Set from boltons import urlutils from citext import CIText +from flask_sqlalchemy import event from ereuse_utils.naming import HID_CONVERSION_DOC, Naming from flask import g from more_itertools import unique_everseen @@ -27,6 +28,7 @@ from teal.marshmallow import ValidationError from teal.resource import url_for_resource from ereuse_devicehub.db import db +from ereuse_devicehub.resources.device.utils import Hashids from ereuse_devicehub.resources.enums import BatteryTechnology, CameraFacing, ComputerChassis, \ DataStorageInterface, DisplayTech, PrinterTechnology, RamFormat, RamInterface, Severity, TransferState from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing, listener_reset_field_updated_in_actual_time @@ -115,6 +117,7 @@ class Device(Thing): owner = db.relationship(User, primaryjoin=owner_id == User.id) allocated = db.Column(Boolean, default=False) allocated.comment = "device is allocated or not." + code = db.Column(db.CIText(), nullable=True, unique=True) _NON_PHYSICAL_PROPS = { 'id', @@ -137,7 +140,8 @@ class Device(Thing): 'version', 'sku', 'image', - 'allocated' + 'allocated', + 'code' } __table_args__ = ( @@ -1023,3 +1027,12 @@ class Manufacturer(db.Model): listener_reset_field_updated_in_actual_time(Device) + + +def create_code(mapper, connection, thing_obj): + """ This function create the code for every device.""" + thing_obj.code = Hashids(thing_obj.id) + +def listener_reset_field_updated_in_actual_time(thing_obj): + """ This function launch a event than listen like a signal when some device is create.""" + event.listen(thing_obj, 'after_create', create_code, propagate=True) From 41cadcc0b39758d9b232b6f6e2fc8ea453e5802e Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 4 Mar 2021 10:19:31 +0100 Subject: [PATCH 04/16] try execute create_code --- .../versions/8cb91ad1cc40_add_code_to_device.py | 10 ++++++++-- ereuse_devicehub/resources/device/models.py | 14 ++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py index 44d7c39a..3e9b2828 100644 --- a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py +++ b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py @@ -5,10 +5,11 @@ Revises: eca457d8b2a4 Create Date: 2021-03-03 10:39:19.331027 """ +import citext +import sqlalchemy as sa from alembic import op from alembic import context -import sqlalchemy as sa -import citext +from ereuse_devicehub.resources.device.utils import Hashids # revision identifiers, used by Alembic. @@ -25,8 +26,13 @@ def get_inv(): return INV +def create_code(context): + _id = context.get_current_parameters()['id'] + return Hashids(_id) + def upgrade(): op.add_column('device', sa.Column('code', citext.CIText(), + default=create_code, nullable=True), schema=f'{get_inv()}') diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index f9c7db13..492b5004 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -1029,10 +1029,12 @@ class Manufacturer(db.Model): listener_reset_field_updated_in_actual_time(Device) -def create_code(mapper, connection, thing_obj): - """ This function create the code for every device.""" - thing_obj.code = Hashids(thing_obj.id) +# def create_code(mapper, connection, thing_obj): + # """ This function create the code for every device.""" + # thing_obj.code = Hashids(thing_obj.id) -def listener_reset_field_updated_in_actual_time(thing_obj): - """ This function launch a event than listen like a signal when some device is create.""" - event.listen(thing_obj, 'after_create', create_code, propagate=True) +# def listener_create_code(thing_obj): + # """ This function launch a event than listen like a signal when some device is create.""" + # event.listen(thing_obj, 'before_create', create_code) + +# listener_create_code(Device) From bf5cae5f960db3888fc44536a0a1bce3fcda598f Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 4 Mar 2021 13:27:29 +0100 Subject: [PATCH 05/16] adding the create code function from ids of devices --- .../versions/8cb91ad1cc40_add_code_to_device.py | 7 +------ ereuse_devicehub/resources/device/models.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py index 3e9b2828..cbf1254e 100644 --- a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py +++ b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py @@ -9,7 +9,6 @@ import citext import sqlalchemy as sa from alembic import op from alembic import context -from ereuse_devicehub.resources.device.utils import Hashids # revision identifiers, used by Alembic. @@ -26,13 +25,9 @@ def get_inv(): return INV -def create_code(context): - _id = context.get_current_parameters()['id'] - return Hashids(_id) - def upgrade(): op.add_column('device', sa.Column('code', citext.CIText(), - default=create_code, + unique=True, nullable=True), schema=f'{get_inv()}') diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 492b5004..255f57c5 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -28,13 +28,19 @@ from teal.marshmallow import ValidationError from teal.resource import url_for_resource from ereuse_devicehub.db import db -from ereuse_devicehub.resources.device.utils import Hashids +from ereuse_devicehub.resources.device.utils import hashids from ereuse_devicehub.resources.enums import BatteryTechnology, CameraFacing, ComputerChassis, \ DataStorageInterface, DisplayTech, PrinterTechnology, RamFormat, RamInterface, Severity, TransferState from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing, listener_reset_field_updated_in_actual_time from ereuse_devicehub.resources.user.models import User +def create_code(context): + _id = Device.query.order_by(Device.id.desc()).first() or 1 + if not _id == 1: + _id = _id.id + 1 + return hashids(_id) + class Device(Thing): """Base class for any type of physical object that can be identified. @@ -117,7 +123,7 @@ class Device(Thing): owner = db.relationship(User, primaryjoin=owner_id == User.id) allocated = db.Column(Boolean, default=False) allocated.comment = "device is allocated or not." - code = db.Column(db.CIText(), nullable=True, unique=True) + code = db.Column(db.CIText(), nullable=True, unique=True, default=create_code) _NON_PHYSICAL_PROPS = { 'id', From 083ce4e66082d0608b7f4c7acfc9e1a865aca914 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 4 Mar 2021 19:24:05 +0100 Subject: [PATCH 06/16] show code in web --- ereuse_devicehub/resources/device/models.py | 1 + ereuse_devicehub/resources/device/schemas.py | 1 + 2 files changed, 2 insertions(+) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 255f57c5..8a0a0120 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -124,6 +124,7 @@ class Device(Thing): allocated = db.Column(Boolean, default=False) allocated.comment = "device is allocated or not." code = db.Column(db.CIText(), nullable=True, unique=True, default=create_code) + code.comment = "device have a unique code." _NON_PHYSICAL_PROPS = { 'id', diff --git a/ereuse_devicehub/resources/device/schemas.py b/ereuse_devicehub/resources/device/schemas.py index 706b7e03..4fc818ea 100644 --- a/ereuse_devicehub/resources/device/schemas.py +++ b/ereuse_devicehub/resources/device/schemas.py @@ -66,6 +66,7 @@ class Device(Thing): sku = SanitizedStr(description=m.Device.sku.comment) image = URL(description=m.Device.image.comment) allocated = Boolean(description=m.Device.allocated.comment) + code = SanitizedStr(description=m.Device.code.comment) @pre_load def from_actions_to_actions_one(self, data: dict): From 3a4410a4ce137ac24fa93e0215e6500f83202f59 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 4 Mar 2021 20:42:50 +0100 Subject: [PATCH 07/16] upgrade actual datas in migration --- .../versions/8cb91ad1cc40_add_code_to_device.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py index cbf1254e..46f0dca9 100644 --- a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py +++ b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py @@ -10,6 +10,10 @@ import sqlalchemy as sa from alembic import op from alembic import context +from ereuse_devicehub.db import db +from ereuse_devicehub.resources.device.utils import hashids +from ereuse_devicehub.resources.device.models import Device + # revision identifiers, used by Alembic. revision = '8cb91ad1cc40' @@ -25,11 +29,22 @@ def get_inv(): return INV +def upgrade_data(): + con = op.get_bind() + devices = con.execute(f"select id from {get_inv()}.device") + for d in devices: + id_dev = d.id + code = hashids(d.id) + sql = f"update {get_inv()}.device set code='{code}' where id={id_dev};" + con.execute(sql) + + def upgrade(): op.add_column('device', sa.Column('code', citext.CIText(), unique=True, nullable=True), schema=f'{get_inv()}') + upgrade_data() def downgrade(): op.drop_column('device', 'code', schema=f'{get_inv()}') From 06dfb9e31e382d8742e539db9423f692919380fa Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 8 Mar 2021 13:06:07 +0100 Subject: [PATCH 08/16] adding hashcode --- .../migrations/versions/8cb91ad1cc40_add_code_to_device.py | 6 ++---- ereuse_devicehub/resources/device/models.py | 4 ++-- ereuse_devicehub/resources/utils.py | 6 ++++++ 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 ereuse_devicehub/resources/utils.py diff --git a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py index 46f0dca9..e8025635 100644 --- a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py +++ b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py @@ -10,9 +10,7 @@ import sqlalchemy as sa from alembic import op from alembic import context -from ereuse_devicehub.db import db -from ereuse_devicehub.resources.device.utils import hashids -from ereuse_devicehub.resources.device.models import Device +from ereuse_devicehub.resources.device.utils import hashcode # revision identifiers, used by Alembic. @@ -34,7 +32,7 @@ def upgrade_data(): devices = con.execute(f"select id from {get_inv()}.device") for d in devices: id_dev = d.id - code = hashids(d.id) + code = hashcode(d.id) sql = f"update {get_inv()}.device set code='{code}' where id={id_dev};" con.execute(sql) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 8a0a0120..2db2b84c 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -28,7 +28,7 @@ from teal.marshmallow import ValidationError from teal.resource import url_for_resource from ereuse_devicehub.db import db -from ereuse_devicehub.resources.device.utils import hashids +from ereuse_devicehub.resources.device.utils import hashcode from ereuse_devicehub.resources.enums import BatteryTechnology, CameraFacing, ComputerChassis, \ DataStorageInterface, DisplayTech, PrinterTechnology, RamFormat, RamInterface, Severity, TransferState from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing, listener_reset_field_updated_in_actual_time @@ -39,7 +39,7 @@ def create_code(context): _id = Device.query.order_by(Device.id.desc()).first() or 1 if not _id == 1: _id = _id.id + 1 - return hashids(_id) + return hashcode.encode(_id) class Device(Thing): diff --git a/ereuse_devicehub/resources/utils.py b/ereuse_devicehub/resources/utils.py new file mode 100644 index 00000000..3d02d610 --- /dev/null +++ b/ereuse_devicehub/resources/utils.py @@ -0,0 +1,6 @@ +from hashids import Hashids +from decouple import config + +ALPHABET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' +SECRET = config('TAG_HASH', '') +hashcode = Hashids(SECRET, min_length=5, alphabet=ALPHABET) From ff964bfe0af5f4bec8d8d5de806450a22a8e0ca2 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 8 Mar 2021 13:22:37 +0100 Subject: [PATCH 09/16] fixing path to hashcode --- .../migrations/versions/8cb91ad1cc40_add_code_to_device.py | 2 +- ereuse_devicehub/resources/device/models.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py index e8025635..bd1e0494 100644 --- a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py +++ b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py @@ -10,7 +10,7 @@ import sqlalchemy as sa from alembic import op from alembic import context -from ereuse_devicehub.resources.device.utils import hashcode +from ereuse_devicehub.resources.utils import hashcode # revision identifiers, used by Alembic. diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 2db2b84c..77f5ae8d 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -28,7 +28,7 @@ from teal.marshmallow import ValidationError from teal.resource import url_for_resource from ereuse_devicehub.db import db -from ereuse_devicehub.resources.device.utils import hashcode +from ereuse_devicehub.resources.utils import hashcode from ereuse_devicehub.resources.enums import BatteryTechnology, CameraFacing, ComputerChassis, \ DataStorageInterface, DisplayTech, PrinterTechnology, RamFormat, RamInterface, Severity, TransferState from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing, listener_reset_field_updated_in_actual_time From 840674e83b923cbcf42aa6f4afe89f42af04dfe5 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 8 Mar 2021 19:09:12 +0100 Subject: [PATCH 10/16] devicehubID instead of code --- .../migrations/versions/8cb91ad1cc40_add_code_to_device.py | 6 +++--- ereuse_devicehub/resources/device/models.py | 6 +++--- ereuse_devicehub/resources/device/schemas.py | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py index bd1e0494..3501450f 100644 --- a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py +++ b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py @@ -33,16 +33,16 @@ def upgrade_data(): for d in devices: id_dev = d.id code = hashcode(d.id) - sql = f"update {get_inv()}.device set code='{code}' where id={id_dev};" + sql = f"update {get_inv()}.device set devicehub_id='{code}' where id={id_dev};" con.execute(sql) def upgrade(): - op.add_column('device', sa.Column('code', citext.CIText(), + op.add_column('device', sa.Column('devicehub_id', citext.CIText(), unique=True, nullable=True), schema=f'{get_inv()}') upgrade_data() def downgrade(): - op.drop_column('device', 'code', schema=f'{get_inv()}') + op.drop_column('device', 'devicehub_id', schema=f'{get_inv()}') diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 77f5ae8d..2b1a7ea7 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -123,8 +123,8 @@ class Device(Thing): owner = db.relationship(User, primaryjoin=owner_id == User.id) allocated = db.Column(Boolean, default=False) allocated.comment = "device is allocated or not." - code = db.Column(db.CIText(), nullable=True, unique=True, default=create_code) - code.comment = "device have a unique code." + devicehub_id = db.Column(db.CIText(), nullable=True, unique=True, default=create_code) + devicehub_id.comment = "device have a unique code." _NON_PHYSICAL_PROPS = { 'id', @@ -148,7 +148,7 @@ class Device(Thing): 'sku', 'image', 'allocated', - 'code' + 'devicehub_id' } __table_args__ = ( diff --git a/ereuse_devicehub/resources/device/schemas.py b/ereuse_devicehub/resources/device/schemas.py index 4fc818ea..9a97d72d 100644 --- a/ereuse_devicehub/resources/device/schemas.py +++ b/ereuse_devicehub/resources/device/schemas.py @@ -66,7 +66,8 @@ class Device(Thing): sku = SanitizedStr(description=m.Device.sku.comment) image = URL(description=m.Device.image.comment) allocated = Boolean(description=m.Device.allocated.comment) - code = SanitizedStr(description=m.Device.code.comment) + devicehub_id = SanitizedStr(data_key='devicehubID', + description=m.Device.devicehub_id.comment) @pre_load def from_actions_to_actions_one(self, data: dict): From b83563e0eafa63efe8761a228acbfb57cb530942 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 8 Mar 2021 22:43:24 +0100 Subject: [PATCH 11/16] swap SystemID for DevicehubID --- ereuse_devicehub/dummy/dummy.py | 5 ++- .../8cb91ad1cc40_add_code_to_device.py | 3 +- .../resources/device/definitions.py | 2 +- ereuse_devicehub/resources/device/models.py | 14 +------ ereuse_devicehub/resources/device/views.py | 8 ++-- .../resources/documents/device_row.py | 6 +-- .../templates/documents/erasure.html | 4 +- ereuse_devicehub/resources/tag/__init__.py | 1 - ereuse_devicehub/resources/tag/view.py | 3 +- tests/files/basic.csv | 4 +- tests/files/proposal_extended_csv_report.csv | 6 +-- tests/test_action.py | 14 ++++--- tests/test_device.py | 32 +++++++------- tests/test_documents.py | 2 +- tests/test_lot.py | 3 +- tests/test_rate.py | 4 +- tests/test_snapshot.py | 42 ++++++++++--------- tests/test_tag.py | 5 ++- tests/test_workbench.py | 12 +++--- 19 files changed, 85 insertions(+), 85 deletions(-) diff --git a/ereuse_devicehub/dummy/dummy.py b/ereuse_devicehub/dummy/dummy.py index 376ccd1b..e3b19b8e 100644 --- a/ereuse_devicehub/dummy/dummy.py +++ b/ereuse_devicehub/dummy/dummy.py @@ -95,6 +95,7 @@ class Dummy: s, _ = user1.post(res=m.Snapshot, data=snapshot) if s.get('uuid', None) == 'ec23c11b-80b6-42cd-ac5c-73ba7acddbc4': sample_pc = s['device']['id'] + sample_pc_devicehub_id = s['device']['devicehubID'] else: pcs.add(s['device']['id']) if s.get('uuid', None) == 'de4f495e-c58b-40e1-a33e-46ab5e84767e': # oreo @@ -180,9 +181,9 @@ class Dummy: res=m.Action) # todo Receive - user1.get(res=Device, item=sample_pc) # Test + user1.get(res=Device, item=sample_pc_devicehub_id) # Test anonymous = self.app.test_client() - html, _ = anonymous.get(res=Device, item=sample_pc, accept=ANY) + html, _ = anonymous.get(res=Device, item=sample_pc_devicehub_id, accept=ANY) assert 'intel core2 duo cpu' in html # For netbook: to preapre -> torepair -> to dispose -> disposed diff --git a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py index 3501450f..d387b26f 100644 --- a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py +++ b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py @@ -32,7 +32,7 @@ def upgrade_data(): devices = con.execute(f"select id from {get_inv()}.device") for d in devices: id_dev = d.id - code = hashcode(d.id) + code = hashcode.encode(d.id) sql = f"update {get_inv()}.device set devicehub_id='{code}' where id={id_dev};" con.execute(sql) @@ -44,5 +44,6 @@ def upgrade(): upgrade_data() + def downgrade(): op.drop_column('device', 'devicehub_id', schema=f'{get_inv()}') diff --git a/ereuse_devicehub/resources/device/definitions.py b/ereuse_devicehub/resources/device/definitions.py index e96302f1..cdc99c05 100644 --- a/ereuse_devicehub/resources/device/definitions.py +++ b/ereuse_devicehub/resources/device/definitions.py @@ -10,7 +10,7 @@ from ereuse_devicehub.resources.device.views import DeviceView, DeviceMergeView, class DeviceDef(Resource): SCHEMA = schemas.Device VIEW = DeviceView - ID_CONVERTER = Converters.int + ID_CONVERTER = Converters.string AUTH = False # We manage this at each view def __init__(self, app, diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 2b1a7ea7..a5376ae4 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -374,7 +374,7 @@ class Device(Thing): if act.type == 'Allocate': allo = {'type': 'Allocate', - 'systemId': self.id, + 'devicehubID': self.devicehub_id, 'finalUserCode': act.final_user_code, 'numEndUsers': act.end_users, 'hid': self.hid, @@ -395,7 +395,7 @@ class Device(Thing): if act.type == 'Deallocate': deallo = {'type': 'Deallocate', - 'systemId': self.id, + 'devicehubID': self.devicehub_id, 'finalUserCode': '', 'numEndUsers': '', 'hid': self.hid, @@ -1035,13 +1035,3 @@ class Manufacturer(db.Model): listener_reset_field_updated_in_actual_time(Device) - -# def create_code(mapper, connection, thing_obj): - # """ This function create the code for every device.""" - # thing_obj.code = Hashids(thing_obj.id) - -# def listener_create_code(thing_obj): - # """ This function launch a event than listen like a signal when some device is create.""" - # event.listen(thing_obj, 'before_create', create_code) - -# listener_create_code(Device) diff --git a/ereuse_devicehub/resources/device/views.py b/ereuse_devicehub/resources/device/views.py index 3dde5e3b..7877000d 100644 --- a/ereuse_devicehub/resources/device/views.py +++ b/ereuse_devicehub/resources/device/views.py @@ -118,7 +118,7 @@ class DeviceView(View): return Response(status=204) raise ValueError('Cannot patch a non computer') - def one(self, id: int): + def one(self, id: str): """Gets one device.""" if not request.authorization: return self.one_public(id) @@ -126,12 +126,12 @@ class DeviceView(View): return self.one_private(id) def one_public(self, id: int): - device = Device.query.filter_by(id=id).one() + device = Device.query.filter_by(devicehub_id=id).one() return render_template('devices/layout.html', device=device, states=states) @auth.Auth.requires_auth - def one_private(self, id: int): - device = Device.query.filter_by(id=id, owner_id=g.user.id).first() + def one_private(self, id: str): + device = Device.query.filter_by(devicehub_id=id, owner_id=g.user.id).first() if not device: return self.one_public(id) return self.schema.jsonify(device) diff --git a/ereuse_devicehub/resources/documents/device_row.py b/ereuse_devicehub/resources/documents/device_row.py index 74a322be..bc24ea86 100644 --- a/ereuse_devicehub/resources/documents/device_row.py +++ b/ereuse_devicehub/resources/documents/device_row.py @@ -42,10 +42,10 @@ class DeviceRow(OrderedDict): software = "{software} {version}".format( software=snapshot.software.name, version=snapshot.version) # General information about device - self['System ID'] = device.id + self['DevicehubID'] = device.devicehub_id self['DocumentID'] = self.document_id self['Public Link'] = '{url}{id}'.format(url=url_for('Device.main', _external=True), - id=device.id) + id=device.devicehub_id) self['Tag 1 Type'] = self['Tag 1 ID'] = self['Tag 1 Organization'] = '' self['Tag 2 Type'] = self['Tag 2 ID'] = self['Tag 2 Organization'] = '' self['Tag 3 Type'] = self['Tag 3 ID'] = self['Tag 3 Organization'] = '' @@ -370,7 +370,7 @@ class ActionRow(OrderedDict): def __init__(self, allocate): super().__init__() # General information about allocates, deallocate and lives - self['SystemId'] = allocate['systemId'] + self['DevicehubID'] = allocate['devicehubID'] self['Hid'] = allocate['hid'] self['Start'] = allocate['start'] self['FinalUserCode'] = allocate['finalUserCode'] diff --git a/ereuse_devicehub/resources/documents/templates/documents/erasure.html b/ereuse_devicehub/resources/documents/templates/documents/erasure.html index d8170767..0a0767d5 100644 --- a/ereuse_devicehub/resources/documents/templates/documents/erasure.html +++ b/ereuse_devicehub/resources/documents/templates/documents/erasure.html @@ -42,13 +42,13 @@
Computer where was erase:
Title: {{ erasure.parent.__format__('ts') }}
-
SystemId: {{ erasure.parent.id }}
+
DevicehubID: {{ erasure.parent.devicehub_id }}
Hid: {{ erasure.parent.hid }}
Tags: {{ erasure.parent.tags }}
Computer where it resides:
Title: {{ erasure.device.parent.__format__('ts') }}
-
SystemId: {{ erasure.device.parent.id }}
+
DevicehubID: {{ erasure.device.parent.devicehub_id }}
Hid: {{ erasure.device.parent.hid }}
Tags: {{ erasure.device.parent.tags }}
diff --git a/ereuse_devicehub/resources/tag/__init__.py b/ereuse_devicehub/resources/tag/__init__.py index e6418e54..a5d09dfe 100644 --- a/ereuse_devicehub/resources/tag/__init__.py +++ b/ereuse_devicehub/resources/tag/__init__.py @@ -35,7 +35,6 @@ class TagDef(Resource): ) super().__init__(app, import_name, static_folder, static_url_path, template_folder, url_prefix, subdomain, url_defaults, root_path, cli_commands) - _get_device_from_tag = app.auth.requires_auth(get_device_from_tag) # DeviceTagView URLs device_view = TagDeviceView.as_view('tag-device-view', definition=self, auth=app.auth) diff --git a/ereuse_devicehub/resources/tag/view.py b/ereuse_devicehub/resources/tag/view.py index 2376635e..0aab1612 100644 --- a/ereuse_devicehub/resources/tag/view.py +++ b/ereuse_devicehub/resources/tag/view.py @@ -66,8 +66,9 @@ class TagDeviceView(View): return app.resources[Device.t].schema.jsonify(tag.device) # noinspection PyMethodOverriding - def put(self, tag_id: str, device_id: str): + def put(self, tag_id: str, device_id: int): """Links an existing tag with a device.""" + device_id = int(device_id) tag = Tag.from_an_id(tag_id).one() # type: Tag if tag.device_id: if tag.device_id == device_id: diff --git a/tests/files/basic.csv b/tests/files/basic.csv index c4962b4d..0583518a 100644 --- a/tests/files/basic.csv +++ b/tests/files/basic.csv @@ -1,2 +1,2 @@ -System ID;DocumentID;Public Link;Tag 1 Type;Tag 1 ID;Tag 1 Organization;Tag 2 Type;Tag 2 ID;Tag 2 Organization;Tag 3 Type;Tag 3 ID;Tag 3 Organization;Device Hardware ID;Device Type;Device Chassis;Device Serial Number;Device Model;Device Manufacturer;Registered in;Registered (process);Updated in (software);Updated in (web);Physical state;Trading state;Processor;RAM (MB);Data Storage Size (MB);Processor 1;Processor 1 Manufacturer;Processor 1 Model;Processor 1 Serial Number;Processor 1 Number of cores;Processor 1 Speed (GHz);Benchmark Processor 1 (points);Benchmark ProcessorSysbench Processor 1 (points);Processor 2;Processor 2 Manufacturer;Processor 2 Model;Processor 2 Serial Number;Processor 2 Number of cores;Processor 2 Speed (GHz);Benchmark Processor 2 (points);Benchmark ProcessorSysbench Processor 2 (points);RamModule 1;RamModule 1 Manufacturer;RamModule 1 Model;RamModule 1 Serial Number;RamModule 1 Size (MB);RamModule 1 Speed (MHz);RamModule 2;RamModule 2 Manufacturer;RamModule 2 Model;RamModule 2 Serial Number;RamModule 2 Size (MB);RamModule 2 Speed (MHz);RamModule 3;RamModule 3 Manufacturer;RamModule 3 Model;RamModule 3 Serial Number;RamModule 3 Size (MB);RamModule 3 Speed (MHz);RamModule 4;RamModule 4 Manufacturer;RamModule 4 Model;RamModule 4 Serial Number;RamModule 4 Size (MB);RamModule 4 Speed (MHz);DataStorage 1;DataStorage 1 Manufacturer;DataStorage 1 Model;DataStorage 1 Serial Number;DataStorage 1 Size (MB);Erasure DataStorage 1;Erasure DataStorage 1 Serial Number;Erasure DataStorage 1 Size (MB);Erasure DataStorage 1 Software;Erasure DataStorage 1 Result;Erasure DataStorage 1 Type;Erasure DataStorage 1 Method;Erasure DataStorage 1 Elapsed (hours);Erasure DataStorage 1 Date;Erasure DataStorage 1 Steps;Erasure DataStorage 1 Steps Start Time;Erasure DataStorage 1 Steps End Time;Benchmark DataStorage 1 Read Speed (MB/s);Benchmark DataStorage 1 Writing speed (MB/s);Test DataStorage 1 Software;Test DataStorage 1 Type;Test DataStorage 1 Result;Test DataStorage 1 Power on (hours used);Test DataStorage 1 Lifetime remaining (percentage);DataStorage 2;DataStorage 2 Manufacturer;DataStorage 2 Model;DataStorage 2 Serial Number;DataStorage 2 Size (MB);Erasure DataStorage 2;Erasure DataStorage 2 Serial Number;Erasure DataStorage 2 Size (MB);Erasure DataStorage 2 Software;Erasure DataStorage 2 Result;Erasure DataStorage 2 Type;Erasure DataStorage 2 Method;Erasure DataStorage 2 Elapsed (hours);Erasure DataStorage 2 Date;Erasure DataStorage 2 Steps;Erasure DataStorage 2 Steps Start Time;Erasure DataStorage 2 Steps End Time;Benchmark DataStorage 2 Read Speed (MB/s);Benchmark DataStorage 2 Writing speed (MB/s);Test DataStorage 2 Software;Test DataStorage 2 Type;Test DataStorage 2 Result;Test DataStorage 2 Power on (hours used);Test DataStorage 2 Lifetime remaining (percentage);DataStorage 3;DataStorage 3 Manufacturer;DataStorage 3 Model;DataStorage 3 Serial Number;DataStorage 3 Size (MB);Erasure DataStorage 3;Erasure DataStorage 3 Serial Number;Erasure DataStorage 3 Size (MB);Erasure DataStorage 3 Software;Erasure DataStorage 3 Result;Erasure DataStorage 3 Type;Erasure DataStorage 3 Method;Erasure DataStorage 3 Elapsed (hours);Erasure DataStorage 3 Date;Erasure DataStorage 3 Steps;Erasure DataStorage 3 Steps Start Time;Erasure DataStorage 3 Steps End Time;Benchmark DataStorage 3 Read Speed (MB/s);Benchmark DataStorage 3 Writing speed (MB/s);Test DataStorage 3 Software;Test DataStorage 3 Type;Test DataStorage 3 Result;Test DataStorage 3 Power on (hours used);Test DataStorage 3 Lifetime remaining (percentage);DataStorage 4;DataStorage 4 Manufacturer;DataStorage 4 Model;DataStorage 4 Serial Number;DataStorage 4 Size (MB);Erasure DataStorage 4;Erasure DataStorage 4 Serial Number;Erasure DataStorage 4 Size (MB);Erasure DataStorage 4 Software;Erasure DataStorage 4 Result;Erasure DataStorage 4 Type;Erasure DataStorage 4 Method;Erasure DataStorage 4 Elapsed (hours);Erasure DataStorage 4 Date;Erasure DataStorage 4 Steps;Erasure DataStorage 4 Steps Start Time;Erasure DataStorage 4 Steps End Time;Benchmark DataStorage 4 Read Speed (MB/s);Benchmark DataStorage 4 Writing speed (MB/s);Test DataStorage 4 Software;Test DataStorage 4 Type;Test DataStorage 4 Result;Test DataStorage 4 Power on (hours used);Test DataStorage 4 Lifetime remaining (percentage);Motherboard 1;Motherboard 1 Manufacturer;Motherboard 1 Model;Motherboard 1 Serial Number;Display 1;Display 1 Manufacturer;Display 1 Model;Display 1 Serial Number;GraphicCard 1;GraphicCard 1 Manufacturer;GraphicCard 1 Model;GraphicCard 1 Serial Number;GraphicCard 1 Memory (MB);GraphicCard 2;GraphicCard 2 Manufacturer;GraphicCard 2 Model;GraphicCard 2 Serial Number;GraphicCard 2 Memory (MB);NetworkAdapter 1;NetworkAdapter 1 Manufacturer;NetworkAdapter 1 Model;NetworkAdapter 1 Serial Number;NetworkAdapter 2;NetworkAdapter 2 Manufacturer;NetworkAdapter 2 Model;NetworkAdapter 2 Serial Number;SoundCard 1;SoundCard 1 Manufacturer;SoundCard 1 Model;SoundCard 1 Serial Number;SoundCard 2;SoundCard 2 Manufacturer;SoundCard 2 Model;SoundCard 2 Serial Number;Device Rate;Device Range;Processor Rate;Processor Range;RAM Rate;RAM Range;Data Storage Rate;Data Storage Range;Price;Benchmark RamSysbench (points) -1;;http://localhost/devices/1;;;;;;;;;;desktop-d1mr-d1ml-d1s;Desktop;Microtower;d1s;d1ml;d1mr;Thu Oct 22 15:36:47 2020;Workbench 11.0;2020-10-22 15:36:47.814316+02:00;;;;p1ml;0;0;Processor 4: model p1ml, S/N p1s;p1mr;p1ml;p1s;;1.6;2410.0;;;;;;;;;;RamModule 3: model rm1ml, S/N rm1s;rm1mr;rm1ml;rm1s;;1333;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GraphicCard 2: model gc1ml, S/N gc1s;gc1mr;gc1ml;gc1s;;;;;;;;;;;;;;;;;;;;;;;1.0;VERY_LOW;1.0;VERY_LOW;1.0;VERY_LOW;1.0;VERY_LOW;; +DevicehubID;DocumentID;Public Link;Tag 1 Type;Tag 1 ID;Tag 1 Organization;Tag 2 Type;Tag 2 ID;Tag 2 Organization;Tag 3 Type;Tag 3 ID;Tag 3 Organization;Device Hardware ID;Device Type;Device Chassis;Device Serial Number;Device Model;Device Manufacturer;Registered in;Registered (process);Updated in (software);Updated in (web);Physical state;Trading state;Processor;RAM (MB);Data Storage Size (MB);Processor 1;Processor 1 Manufacturer;Processor 1 Model;Processor 1 Serial Number;Processor 1 Number of cores;Processor 1 Speed (GHz);Benchmark Processor 1 (points);Benchmark ProcessorSysbench Processor 1 (points);Processor 2;Processor 2 Manufacturer;Processor 2 Model;Processor 2 Serial Number;Processor 2 Number of cores;Processor 2 Speed (GHz);Benchmark Processor 2 (points);Benchmark ProcessorSysbench Processor 2 (points);RamModule 1;RamModule 1 Manufacturer;RamModule 1 Model;RamModule 1 Serial Number;RamModule 1 Size (MB);RamModule 1 Speed (MHz);RamModule 2;RamModule 2 Manufacturer;RamModule 2 Model;RamModule 2 Serial Number;RamModule 2 Size (MB);RamModule 2 Speed (MHz);RamModule 3;RamModule 3 Manufacturer;RamModule 3 Model;RamModule 3 Serial Number;RamModule 3 Size (MB);RamModule 3 Speed (MHz);RamModule 4;RamModule 4 Manufacturer;RamModule 4 Model;RamModule 4 Serial Number;RamModule 4 Size (MB);RamModule 4 Speed (MHz);DataStorage 1;DataStorage 1 Manufacturer;DataStorage 1 Model;DataStorage 1 Serial Number;DataStorage 1 Size (MB);Erasure DataStorage 1;Erasure DataStorage 1 Serial Number;Erasure DataStorage 1 Size (MB);Erasure DataStorage 1 Software;Erasure DataStorage 1 Result;Erasure DataStorage 1 Type;Erasure DataStorage 1 Method;Erasure DataStorage 1 Elapsed (hours);Erasure DataStorage 1 Date;Erasure DataStorage 1 Steps;Erasure DataStorage 1 Steps Start Time;Erasure DataStorage 1 Steps End Time;Benchmark DataStorage 1 Read Speed (MB/s);Benchmark DataStorage 1 Writing speed (MB/s);Test DataStorage 1 Software;Test DataStorage 1 Type;Test DataStorage 1 Result;Test DataStorage 1 Power on (hours used);Test DataStorage 1 Lifetime remaining (percentage);DataStorage 2;DataStorage 2 Manufacturer;DataStorage 2 Model;DataStorage 2 Serial Number;DataStorage 2 Size (MB);Erasure DataStorage 2;Erasure DataStorage 2 Serial Number;Erasure DataStorage 2 Size (MB);Erasure DataStorage 2 Software;Erasure DataStorage 2 Result;Erasure DataStorage 2 Type;Erasure DataStorage 2 Method;Erasure DataStorage 2 Elapsed (hours);Erasure DataStorage 2 Date;Erasure DataStorage 2 Steps;Erasure DataStorage 2 Steps Start Time;Erasure DataStorage 2 Steps End Time;Benchmark DataStorage 2 Read Speed (MB/s);Benchmark DataStorage 2 Writing speed (MB/s);Test DataStorage 2 Software;Test DataStorage 2 Type;Test DataStorage 2 Result;Test DataStorage 2 Power on (hours used);Test DataStorage 2 Lifetime remaining (percentage);DataStorage 3;DataStorage 3 Manufacturer;DataStorage 3 Model;DataStorage 3 Serial Number;DataStorage 3 Size (MB);Erasure DataStorage 3;Erasure DataStorage 3 Serial Number;Erasure DataStorage 3 Size (MB);Erasure DataStorage 3 Software;Erasure DataStorage 3 Result;Erasure DataStorage 3 Type;Erasure DataStorage 3 Method;Erasure DataStorage 3 Elapsed (hours);Erasure DataStorage 3 Date;Erasure DataStorage 3 Steps;Erasure DataStorage 3 Steps Start Time;Erasure DataStorage 3 Steps End Time;Benchmark DataStorage 3 Read Speed (MB/s);Benchmark DataStorage 3 Writing speed (MB/s);Test DataStorage 3 Software;Test DataStorage 3 Type;Test DataStorage 3 Result;Test DataStorage 3 Power on (hours used);Test DataStorage 3 Lifetime remaining (percentage);DataStorage 4;DataStorage 4 Manufacturer;DataStorage 4 Model;DataStorage 4 Serial Number;DataStorage 4 Size (MB);Erasure DataStorage 4;Erasure DataStorage 4 Serial Number;Erasure DataStorage 4 Size (MB);Erasure DataStorage 4 Software;Erasure DataStorage 4 Result;Erasure DataStorage 4 Type;Erasure DataStorage 4 Method;Erasure DataStorage 4 Elapsed (hours);Erasure DataStorage 4 Date;Erasure DataStorage 4 Steps;Erasure DataStorage 4 Steps Start Time;Erasure DataStorage 4 Steps End Time;Benchmark DataStorage 4 Read Speed (MB/s);Benchmark DataStorage 4 Writing speed (MB/s);Test DataStorage 4 Software;Test DataStorage 4 Type;Test DataStorage 4 Result;Test DataStorage 4 Power on (hours used);Test DataStorage 4 Lifetime remaining (percentage);Motherboard 1;Motherboard 1 Manufacturer;Motherboard 1 Model;Motherboard 1 Serial Number;Display 1;Display 1 Manufacturer;Display 1 Model;Display 1 Serial Number;GraphicCard 1;GraphicCard 1 Manufacturer;GraphicCard 1 Model;GraphicCard 1 Serial Number;GraphicCard 1 Memory (MB);GraphicCard 2;GraphicCard 2 Manufacturer;GraphicCard 2 Model;GraphicCard 2 Serial Number;GraphicCard 2 Memory (MB);NetworkAdapter 1;NetworkAdapter 1 Manufacturer;NetworkAdapter 1 Model;NetworkAdapter 1 Serial Number;NetworkAdapter 2;NetworkAdapter 2 Manufacturer;NetworkAdapter 2 Model;NetworkAdapter 2 Serial Number;SoundCard 1;SoundCard 1 Manufacturer;SoundCard 1 Model;SoundCard 1 Serial Number;SoundCard 2;SoundCard 2 Manufacturer;SoundCard 2 Model;SoundCard 2 Serial Number;Device Rate;Device Range;Processor Rate;Processor Range;RAM Rate;RAM Range;Data Storage Rate;Data Storage Range;Price;Benchmark RamSysbench (points) +LE94J;;http://localhost/devices/LE94J;;;;;;;;;;desktop-d1mr-d1ml-d1s;Desktop;Microtower;d1s;d1ml;d1mr;Thu Oct 22 15:36:47 2020;Workbench 11.0;2020-10-22 15:36:47.814316+02:00;;;;p1ml;0;0;Processor 4: model p1ml, S/N p1s;p1mr;p1ml;p1s;;1.6;2410.0;;;;;;;;;;RamModule 3: model rm1ml, S/N rm1s;rm1mr;rm1ml;rm1s;;1333;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GraphicCard 2: model gc1ml, S/N gc1s;gc1mr;gc1ml;gc1s;;;;;;;;;;;;;;;;;;;;;;;1.0;VERY_LOW;1.0;VERY_LOW;1.0;VERY_LOW;1.0;VERY_LOW;; diff --git a/tests/files/proposal_extended_csv_report.csv b/tests/files/proposal_extended_csv_report.csv index 63709330..6a27c461 100644 --- a/tests/files/proposal_extended_csv_report.csv +++ b/tests/files/proposal_extended_csv_report.csv @@ -1,3 +1,3 @@ -System ID;DocumentID;Public Link;Tag 1 Type;Tag 1 ID;Tag 1 Organization;Tag 2 Type;Tag 2 ID;Tag 2 Organization;Tag 3 Type;Tag 3 ID;Tag 3 Organization;Device Hardware ID;Device Type;Device Chassis;Device Serial Number;Device Model;Device Manufacturer;Registered in;Registered (process);Updated in (software);Updated in (web);Physical state;Trading state;Processor;RAM (MB);Data Storage Size (MB);Processor 1;Processor 1 Manufacturer;Processor 1 Model;Processor 1 Serial Number;Processor 1 Number of cores;Processor 1 Speed (GHz);Benchmark Processor 1 (points);Benchmark ProcessorSysbench Processor 1 (points);Processor 2;Processor 2 Manufacturer;Processor 2 Model;Processor 2 Serial Number;Processor 2 Number of cores;Processor 2 Speed (GHz);Benchmark Processor 2 (points);Benchmark ProcessorSysbench Processor 2 (points);RamModule 1;RamModule 1 Manufacturer;RamModule 1 Model;RamModule 1 Serial Number;RamModule 1 Size (MB);RamModule 1 Speed (MHz);RamModule 2;RamModule 2 Manufacturer;RamModule 2 Model;RamModule 2 Serial Number;RamModule 2 Size (MB);RamModule 2 Speed (MHz);RamModule 3;RamModule 3 Manufacturer;RamModule 3 Model;RamModule 3 Serial Number;RamModule 3 Size (MB);RamModule 3 Speed (MHz);RamModule 4;RamModule 4 Manufacturer;RamModule 4 Model;RamModule 4 Serial Number;RamModule 4 Size (MB);RamModule 4 Speed (MHz);DataStorage 1;DataStorage 1 Manufacturer;DataStorage 1 Model;DataStorage 1 Serial Number;DataStorage 1 Size (MB);Erasure DataStorage 1;Erasure DataStorage 1 Serial Number;Erasure DataStorage 1 Size (MB);Erasure DataStorage 1 Software;Erasure DataStorage 1 Result;Erasure DataStorage 1 Type;Erasure DataStorage 1 Method;Erasure DataStorage 1 Elapsed (hours);Erasure DataStorage 1 Date;Erasure DataStorage 1 Steps;Erasure DataStorage 1 Steps Start Time;Erasure DataStorage 1 Steps End Time;Benchmark DataStorage 1 Read Speed (MB/s);Benchmark DataStorage 1 Writing speed (MB/s);Test DataStorage 1 Software;Test DataStorage 1 Type;Test DataStorage 1 Result;Test DataStorage 1 Power on (hours used);Test DataStorage 1 Lifetime remaining (percentage);DataStorage 2;DataStorage 2 Manufacturer;DataStorage 2 Model;DataStorage 2 Serial Number;DataStorage 2 Size (MB);Erasure DataStorage 2;Erasure DataStorage 2 Serial Number;Erasure DataStorage 2 Size (MB);Erasure DataStorage 2 Software;Erasure DataStorage 2 Result;Erasure DataStorage 2 Type;Erasure DataStorage 2 Method;Erasure DataStorage 2 Elapsed (hours);Erasure DataStorage 2 Date;Erasure DataStorage 2 Steps;Erasure DataStorage 2 Steps Start Time;Erasure DataStorage 2 Steps End Time;Benchmark DataStorage 2 Read Speed (MB/s);Benchmark DataStorage 2 Writing speed (MB/s);Test DataStorage 2 Software;Test DataStorage 2 Type;Test DataStorage 2 Result;Test DataStorage 2 Power on (hours used);Test DataStorage 2 Lifetime remaining (percentage);DataStorage 3;DataStorage 3 Manufacturer;DataStorage 3 Model;DataStorage 3 Serial Number;DataStorage 3 Size (MB);Erasure DataStorage 3;Erasure DataStorage 3 Serial Number;Erasure DataStorage 3 Size (MB);Erasure DataStorage 3 Software;Erasure DataStorage 3 Result;Erasure DataStorage 3 Type;Erasure DataStorage 3 Method;Erasure DataStorage 3 Elapsed (hours);Erasure DataStorage 3 Date;Erasure DataStorage 3 Steps;Erasure DataStorage 3 Steps Start Time;Erasure DataStorage 3 Steps End Time;Benchmark DataStorage 3 Read Speed (MB/s);Benchmark DataStorage 3 Writing speed (MB/s);Test DataStorage 3 Software;Test DataStorage 3 Type;Test DataStorage 3 Result;Test DataStorage 3 Power on (hours used);Test DataStorage 3 Lifetime remaining (percentage);DataStorage 4;DataStorage 4 Manufacturer;DataStorage 4 Model;DataStorage 4 Serial Number;DataStorage 4 Size (MB);Erasure DataStorage 4;Erasure DataStorage 4 Serial Number;Erasure DataStorage 4 Size (MB);Erasure DataStorage 4 Software;Erasure DataStorage 4 Result;Erasure DataStorage 4 Type;Erasure DataStorage 4 Method;Erasure DataStorage 4 Elapsed (hours);Erasure DataStorage 4 Date;Erasure DataStorage 4 Steps;Erasure DataStorage 4 Steps Start Time;Erasure DataStorage 4 Steps End Time;Benchmark DataStorage 4 Read Speed (MB/s);Benchmark DataStorage 4 Writing speed (MB/s);Test DataStorage 4 Software;Test DataStorage 4 Type;Test DataStorage 4 Result;Test DataStorage 4 Power on (hours used);Test DataStorage 4 Lifetime remaining (percentage);Motherboard 1;Motherboard 1 Manufacturer;Motherboard 1 Model;Motherboard 1 Serial Number;Display 1;Display 1 Manufacturer;Display 1 Model;Display 1 Serial Number;GraphicCard 1;GraphicCard 1 Manufacturer;GraphicCard 1 Model;GraphicCard 1 Serial Number;GraphicCard 1 Memory (MB);GraphicCard 2;GraphicCard 2 Manufacturer;GraphicCard 2 Model;GraphicCard 2 Serial Number;GraphicCard 2 Memory (MB);NetworkAdapter 1;NetworkAdapter 1 Manufacturer;NetworkAdapter 1 Model;NetworkAdapter 1 Serial Number;NetworkAdapter 2;NetworkAdapter 2 Manufacturer;NetworkAdapter 2 Model;NetworkAdapter 2 Serial Number;SoundCard 1;SoundCard 1 Manufacturer;SoundCard 1 Model;SoundCard 1 Serial Number;SoundCard 2;SoundCard 2 Manufacturer;SoundCard 2 Model;SoundCard 2 Serial Number;Device Rate;Device Range;Processor Rate;Processor Range;RAM Rate;RAM Range;Data Storage Rate;Data Storage Range;Price;Benchmark RamSysbench (points) -1;;http://localhost/devices/1;unamed;foo;FooOrg;;;;;;;laptop-asustek_computer_inc-1001pxd-b8oaas048285-14:da:e9:42:f6:7b;Laptop;Netbook;b8oaas048285;1001pxd;asustek computer inc.;Thu Nov 12 19:53:01 2020;Workbench 11.0a2;2020-11-12 19:54:03.959185+01:00;;;;intel atom cpu n455 @ 2.66ghz;1024;238475;Processor 4: model intel atom cpu n455 @ 2.66ghz, S/N None;intel corp.;intel atom cpu n455 @ 2.66ghz;;1;2.667;6666.24;164.0803;;;;;;;;;RamModule 8: model None, S/N None;;;;1024;667;;;;;;;;;;;;;;;;;;;HardDrive 9: model hts54322, S/N e2024242cv86mm;hitachi;hts54322;e2024242cv86mm;238475;harddrive-hitachi-hts54322-e2024242cv86mm;e2024242cv86mm;238475;Workbench 11.0a2;Success;EraseBasic;Shred;1:16:49;2020-11-12 19:53:01.899092+01:00;✓ – StepRandom 1:16:49;2018-07-03 11:15:22.257059+02:00;2018-07-03 12:32:11.843190+02:00;66.2;21.8;Workbench 11.0a2;Short;Failure;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Motherboard 10: model 1001pxd, S/N eee0123456720;asustek computer inc.;1001pxd;eee0123456720;;;;;GraphicCard 5: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None;intel corporation;atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller;;256;;;;;;NetworkAdapter 2: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c9;qualcomm atheros;ar9285 wireless network adapter;74:2f:68:8b:fd:c9;NetworkAdapter 3: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7b;qualcomm atheros;ar8152 v2.0 fast ethernet;14:da:e9:42:f6:7b;SoundCard 6: model nm10/ich7 family high definition audio controller, S/N None;intel corporation;nm10/ich7 family high definition audio controller;;;;;;1.75;LOW;1.55;LOW;1.53;LOW;3.76;HIGH;52.50 €;15.7188 -11;;http://localhost/devices/11;;;;;;;;;;laptop-asustek_computer_inc-1001pxd-b8oaas048287-14:da:e9:42:f6:7c;Laptop;Netbook;b8oaas048287;1001pxd;asustek computer inc.;Thu Nov 12 19:53:02 2020;Workbench 11.0b11;2020-11-12 19:53:02.225373+01:00;;;;intel atom cpu n455 @ 1.66ghz;2048;558558;Processor 15: model intel atom cpu n455 @ 1.66ghz, S/N None;intel corp.;intel atom cpu n455 @ 1.66ghz;;1;1.667;6666.24;164.0803;;;;;;;;;RamModule 18: model None, S/N None;;;;1024;667;RamModule 19: model 48594d503131325336344350362d53362020, S/N 4f43487b;hynix semiconductor;48594d503131325336344350362d53362020;4f43487b;1024;667;;;;;;;;;;;;;HardDrive 20: model hts54322, S/N e2024242cv86hj;hitachi;hts54322;e2024242cv86hj;238475;harddrive-hitachi-hts54322-e2024242cv86hj;e2024242cv86hj;238475;Workbench 11.0b11;Success;EraseBasic;Shred;1:16:49;2020-11-12 19:53:02.175189+01:00;✓ – StepRandom 1:16:49;2018-07-03 11:15:22.257059+02:00;2018-07-03 12:32:11.843190+02:00;66.2;21.8;Workbench 11.0b11;Extended;Failure;;;DataStorage 21: model wdc wd1600bevt-2, S/N wd-wx11a80w7430;western digital;wdc wd1600bevt-2;wd-wx11a80w7430;160041;datastorage-western_digital-wdc_wd1600bevt-2-wd-wx11a80w7430;wd-wx11a80w7430;160041;Workbench 11.0b11;Failure;EraseBasic;Shred;0:45:36;2020-11-12 19:53:02.176882+01:00;✓ – StepRandom 0:45:36;2019-10-23 09:49:54.410830+02:00;2019-10-23 10:35:31.400587+02:00;41.6;17.3;Workbench 11.0b11;Short;Success;5293;195 days, 12:00:00;SolidStateDrive 22: model wdc wd1600bevt-2, S/N wd-wx11a80w7430;western digital;wdc wd1600bevt-2;wd-wx11a80w7430;160042;solidstatedrive-western_digital-wdc_wd1600bevt-2-wd-wx11a80w7430;wd-wx11a80w7430;160042;Workbench 11.0b11;Success;EraseSectors;Badblocks;1:46:03;2020-11-12 19:53:02.180043+01:00;✓ – StepRandom 0:46:03,✓ – StepZero 1:00:00;2019-08-19 18:48:19.690458+02:00,2019-08-19 19:34:22.690458+02:00;2019-08-19 19:34:22.930562+02:00,2019-08-19 20:34:22.930562+02:00;41.1;17.1;Workbench 11.0b11;Short;Success;5231;194 days, 17:00:00;;;;;;;;;;;;;;;;;;;;;;;;;Motherboard 23: model 1001pxd, S/N eee0123456789;asustek computer inc.;1001pxd;eee0123456789;;"auo ""auo""";auo lcd monitor;;GraphicCard 16: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None;intel corporation;atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller;;256;;;;;;NetworkAdapter 13: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c8;qualcomm atheros;ar9285 wireless network adapter;74:2f:68:8b:fd:c8;NetworkAdapter 14: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7c;qualcomm atheros;ar8152 v2.0 fast ethernet;14:da:e9:42:f6:7c;SoundCard 7: model usb 2.0 uvc vga webcam, S/N 0x0001;azurewave;usb 2.0 uvc vga webcam;0x0001;SoundCard 17: model nm10/ich7 family high definition audio controller, S/N None;intel corporation;nm10/ich7 family high definition audio controller;;1.72;LOW;1.31;LOW;1.99;LOW;3.97;HIGH;51.60 €;15.7188 +DevicehubID;DocumentID;Public Link;Tag 1 Type;Tag 1 ID;Tag 1 Organization;Tag 2 Type;Tag 2 ID;Tag 2 Organization;Tag 3 Type;Tag 3 ID;Tag 3 Organization;Device Hardware ID;Device Type;Device Chassis;Device Serial Number;Device Model;Device Manufacturer;Registered in;Registered (process);Updated in (software);Updated in (web);Physical state;Trading state;Processor;RAM (MB);Data Storage Size (MB);Processor 1;Processor 1 Manufacturer;Processor 1 Model;Processor 1 Serial Number;Processor 1 Number of cores;Processor 1 Speed (GHz);Benchmark Processor 1 (points);Benchmark ProcessorSysbench Processor 1 (points);Processor 2;Processor 2 Manufacturer;Processor 2 Model;Processor 2 Serial Number;Processor 2 Number of cores;Processor 2 Speed (GHz);Benchmark Processor 2 (points);Benchmark ProcessorSysbench Processor 2 (points);RamModule 1;RamModule 1 Manufacturer;RamModule 1 Model;RamModule 1 Serial Number;RamModule 1 Size (MB);RamModule 1 Speed (MHz);RamModule 2;RamModule 2 Manufacturer;RamModule 2 Model;RamModule 2 Serial Number;RamModule 2 Size (MB);RamModule 2 Speed (MHz);RamModule 3;RamModule 3 Manufacturer;RamModule 3 Model;RamModule 3 Serial Number;RamModule 3 Size (MB);RamModule 3 Speed (MHz);RamModule 4;RamModule 4 Manufacturer;RamModule 4 Model;RamModule 4 Serial Number;RamModule 4 Size (MB);RamModule 4 Speed (MHz);DataStorage 1;DataStorage 1 Manufacturer;DataStorage 1 Model;DataStorage 1 Serial Number;DataStorage 1 Size (MB);Erasure DataStorage 1;Erasure DataStorage 1 Serial Number;Erasure DataStorage 1 Size (MB);Erasure DataStorage 1 Software;Erasure DataStorage 1 Result;Erasure DataStorage 1 Type;Erasure DataStorage 1 Method;Erasure DataStorage 1 Elapsed (hours);Erasure DataStorage 1 Date;Erasure DataStorage 1 Steps;Erasure DataStorage 1 Steps Start Time;Erasure DataStorage 1 Steps End Time;Benchmark DataStorage 1 Read Speed (MB/s);Benchmark DataStorage 1 Writing speed (MB/s);Test DataStorage 1 Software;Test DataStorage 1 Type;Test DataStorage 1 Result;Test DataStorage 1 Power on (hours used);Test DataStorage 1 Lifetime remaining (percentage);DataStorage 2;DataStorage 2 Manufacturer;DataStorage 2 Model;DataStorage 2 Serial Number;DataStorage 2 Size (MB);Erasure DataStorage 2;Erasure DataStorage 2 Serial Number;Erasure DataStorage 2 Size (MB);Erasure DataStorage 2 Software;Erasure DataStorage 2 Result;Erasure DataStorage 2 Type;Erasure DataStorage 2 Method;Erasure DataStorage 2 Elapsed (hours);Erasure DataStorage 2 Date;Erasure DataStorage 2 Steps;Erasure DataStorage 2 Steps Start Time;Erasure DataStorage 2 Steps End Time;Benchmark DataStorage 2 Read Speed (MB/s);Benchmark DataStorage 2 Writing speed (MB/s);Test DataStorage 2 Software;Test DataStorage 2 Type;Test DataStorage 2 Result;Test DataStorage 2 Power on (hours used);Test DataStorage 2 Lifetime remaining (percentage);DataStorage 3;DataStorage 3 Manufacturer;DataStorage 3 Model;DataStorage 3 Serial Number;DataStorage 3 Size (MB);Erasure DataStorage 3;Erasure DataStorage 3 Serial Number;Erasure DataStorage 3 Size (MB);Erasure DataStorage 3 Software;Erasure DataStorage 3 Result;Erasure DataStorage 3 Type;Erasure DataStorage 3 Method;Erasure DataStorage 3 Elapsed (hours);Erasure DataStorage 3 Date;Erasure DataStorage 3 Steps;Erasure DataStorage 3 Steps Start Time;Erasure DataStorage 3 Steps End Time;Benchmark DataStorage 3 Read Speed (MB/s);Benchmark DataStorage 3 Writing speed (MB/s);Test DataStorage 3 Software;Test DataStorage 3 Type;Test DataStorage 3 Result;Test DataStorage 3 Power on (hours used);Test DataStorage 3 Lifetime remaining (percentage);DataStorage 4;DataStorage 4 Manufacturer;DataStorage 4 Model;DataStorage 4 Serial Number;DataStorage 4 Size (MB);Erasure DataStorage 4;Erasure DataStorage 4 Serial Number;Erasure DataStorage 4 Size (MB);Erasure DataStorage 4 Software;Erasure DataStorage 4 Result;Erasure DataStorage 4 Type;Erasure DataStorage 4 Method;Erasure DataStorage 4 Elapsed (hours);Erasure DataStorage 4 Date;Erasure DataStorage 4 Steps;Erasure DataStorage 4 Steps Start Time;Erasure DataStorage 4 Steps End Time;Benchmark DataStorage 4 Read Speed (MB/s);Benchmark DataStorage 4 Writing speed (MB/s);Test DataStorage 4 Software;Test DataStorage 4 Type;Test DataStorage 4 Result;Test DataStorage 4 Power on (hours used);Test DataStorage 4 Lifetime remaining (percentage);Motherboard 1;Motherboard 1 Manufacturer;Motherboard 1 Model;Motherboard 1 Serial Number;Display 1;Display 1 Manufacturer;Display 1 Model;Display 1 Serial Number;GraphicCard 1;GraphicCard 1 Manufacturer;GraphicCard 1 Model;GraphicCard 1 Serial Number;GraphicCard 1 Memory (MB);GraphicCard 2;GraphicCard 2 Manufacturer;GraphicCard 2 Model;GraphicCard 2 Serial Number;GraphicCard 2 Memory (MB);NetworkAdapter 1;NetworkAdapter 1 Manufacturer;NetworkAdapter 1 Model;NetworkAdapter 1 Serial Number;NetworkAdapter 2;NetworkAdapter 2 Manufacturer;NetworkAdapter 2 Model;NetworkAdapter 2 Serial Number;SoundCard 1;SoundCard 1 Manufacturer;SoundCard 1 Model;SoundCard 1 Serial Number;SoundCard 2;SoundCard 2 Manufacturer;SoundCard 2 Model;SoundCard 2 Serial Number;Device Rate;Device Range;Processor Rate;Processor Range;RAM Rate;RAM Range;Data Storage Rate;Data Storage Range;Price;Benchmark RamSysbench (points) +LE94J;;http://localhost/devices/LE94J;unamed;foo;FooOrg;;;;;;;laptop-asustek_computer_inc-1001pxd-b8oaas048285-14:da:e9:42:f6:7b;Laptop;Netbook;b8oaas048285;1001pxd;asustek computer inc.;Thu Nov 12 19:53:01 2020;Workbench 11.0a2;2020-11-12 19:54:03.959185+01:00;;;;intel atom cpu n455 @ 2.66ghz;1024;238475;Processor 4: model intel atom cpu n455 @ 2.66ghz, S/N None;intel corp.;intel atom cpu n455 @ 2.66ghz;;1;2.667;6666.24;164.0803;;;;;;;;;RamModule 8: model None, S/N None;;;;1024;667;;;;;;;;;;;;;;;;;;;HardDrive 9: model hts54322, S/N e2024242cv86mm;hitachi;hts54322;e2024242cv86mm;238475;harddrive-hitachi-hts54322-e2024242cv86mm;e2024242cv86mm;238475;Workbench 11.0a2;Success;EraseBasic;Shred;1:16:49;2020-11-12 19:53:01.899092+01:00;✓ – StepRandom 1:16:49;2018-07-03 11:15:22.257059+02:00;2018-07-03 12:32:11.843190+02:00;66.2;21.8;Workbench 11.0a2;Short;Failure;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Motherboard 10: model 1001pxd, S/N eee0123456720;asustek computer inc.;1001pxd;eee0123456720;;;;;GraphicCard 5: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None;intel corporation;atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller;;256;;;;;;NetworkAdapter 2: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c9;qualcomm atheros;ar9285 wireless network adapter;74:2f:68:8b:fd:c9;NetworkAdapter 3: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7b;qualcomm atheros;ar8152 v2.0 fast ethernet;14:da:e9:42:f6:7b;SoundCard 6: model nm10/ich7 family high definition audio controller, S/N None;intel corporation;nm10/ich7 family high definition audio controller;;;;;;1.75;LOW;1.55;LOW;1.53;LOW;3.76;HIGH;52.50 €;15.7188 +XE5XZ;;http://localhost/devices/XE5XZ;;;;;;;;;;laptop-asustek_computer_inc-1001pxd-b8oaas048287-14:da:e9:42:f6:7c;Laptop;Netbook;b8oaas048287;1001pxd;asustek computer inc.;Thu Nov 12 19:53:02 2020;Workbench 11.0b11;2020-11-12 19:53:02.225373+01:00;;;;intel atom cpu n455 @ 1.66ghz;2048;558558;Processor 15: model intel atom cpu n455 @ 1.66ghz, S/N None;intel corp.;intel atom cpu n455 @ 1.66ghz;;1;1.667;6666.24;164.0803;;;;;;;;;RamModule 18: model None, S/N None;;;;1024;667;RamModule 19: model 48594d503131325336344350362d53362020, S/N 4f43487b;hynix semiconductor;48594d503131325336344350362d53362020;4f43487b;1024;667;;;;;;;;;;;;;HardDrive 20: model hts54322, S/N e2024242cv86hj;hitachi;hts54322;e2024242cv86hj;238475;harddrive-hitachi-hts54322-e2024242cv86hj;e2024242cv86hj;238475;Workbench 11.0b11;Success;EraseBasic;Shred;1:16:49;2020-11-12 19:53:02.175189+01:00;✓ – StepRandom 1:16:49;2018-07-03 11:15:22.257059+02:00;2018-07-03 12:32:11.843190+02:00;66.2;21.8;Workbench 11.0b11;Extended;Failure;;;DataStorage 21: model wdc wd1600bevt-2, S/N wd-wx11a80w7430;western digital;wdc wd1600bevt-2;wd-wx11a80w7430;160041;datastorage-western_digital-wdc_wd1600bevt-2-wd-wx11a80w7430;wd-wx11a80w7430;160041;Workbench 11.0b11;Failure;EraseBasic;Shred;0:45:36;2020-11-12 19:53:02.176882+01:00;✓ – StepRandom 0:45:36;2019-10-23 09:49:54.410830+02:00;2019-10-23 10:35:31.400587+02:00;41.6;17.3;Workbench 11.0b11;Short;Success;5293;195 days, 12:00:00;SolidStateDrive 22: model wdc wd1600bevt-2, S/N wd-wx11a80w7430;western digital;wdc wd1600bevt-2;wd-wx11a80w7430;160042;solidstatedrive-western_digital-wdc_wd1600bevt-2-wd-wx11a80w7430;wd-wx11a80w7430;160042;Workbench 11.0b11;Success;EraseSectors;Badblocks;1:46:03;2020-11-12 19:53:02.180043+01:00;✓ – StepRandom 0:46:03,✓ – StepZero 1:00:00;2019-08-19 18:48:19.690458+02:00,2019-08-19 19:34:22.690458+02:00;2019-08-19 19:34:22.930562+02:00,2019-08-19 20:34:22.930562+02:00;41.1;17.1;Workbench 11.0b11;Short;Success;5231;194 days, 17:00:00;;;;;;;;;;;;;;;;;;;;;;;;;Motherboard 23: model 1001pxd, S/N eee0123456789;asustek computer inc.;1001pxd;eee0123456789;;"auo ""auo""";auo lcd monitor;;GraphicCard 16: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None;intel corporation;atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller;;256;;;;;;NetworkAdapter 13: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c8;qualcomm atheros;ar9285 wireless network adapter;74:2f:68:8b:fd:c8;NetworkAdapter 14: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7c;qualcomm atheros;ar8152 v2.0 fast ethernet;14:da:e9:42:f6:7c;SoundCard 7: model usb 2.0 uvc vga webcam, S/N 0x0001;azurewave;usb 2.0 uvc vga webcam;0x0001;SoundCard 17: model nm10/ich7 family high definition audio controller, S/N None;intel corporation;nm10/ich7 family high definition audio controller;;1.72;LOW;1.31;LOW;1.99;LOW;3.97;HIGH;51.60 €;15.7188 diff --git a/tests/test_action.py b/tests/test_action.py index 421a5c80..2401b7c4 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -242,7 +242,7 @@ def test_generic_action(action_model_state: Tuple[models.Action, states.Trading] action = {'type': action_model.t, 'devices': [snapshot['device']['id']]} action, _ = user.post(action, res=models.Action) assert action['devices'][0]['id'] == snapshot['device']['id'] - device, _ = user.get(res=Device, item=snapshot['device']['id']) + device, _ = user.get(res=Device, item=snapshot['device']['devicehubID']) assert device['actions'][-1]['id'] == action['id'] assert device['physical'] == state.name # Check if the update of device is changed @@ -625,6 +625,7 @@ def test_allocate(user: UserClient): """ Tests allocate """ snapshot, _ = user.post(file('basic.snapshot'), res=models.Snapshot) device_id = snapshot['device']['id'] + devicehub_id = snapshot['device']['devicehubID'] post_request = {"transaction": "ccc", "finalUserCode": "aabbcc", "name": "John", @@ -638,7 +639,7 @@ def test_allocate(user: UserClient): allocate, _ = user.post(res=models.Allocate, data=post_request) # Normal allocate - device, _ = user.get(res=Device, item=device_id) + device, _ = user.get(res=Device, item=devicehub_id) assert device['allocated'] == True action = [a for a in device['actions'] if a['type'] == 'Allocate'][0] assert action['transaction'] == allocate['transaction'] @@ -691,6 +692,7 @@ def test_deallocate(user: UserClient): """ Tests deallocate """ snapshot, _ = user.post(file('basic.snapshot'), res=models.Snapshot) device_id = snapshot['device']['id'] + devicehub_id = snapshot['device']['devicehubID'] post_deallocate = {"startTime": "2020-11-01T02:00:00+00:00", "transaction": "ccc", "devices": [device_id] @@ -705,7 +707,7 @@ def test_deallocate(user: UserClient): } user.post(res=models.Allocate, data=post_allocate) - device, _ = user.get(res=Device, item=device_id) + device, _ = user.get(res=Device, item=devicehub_id) assert device['allocated'] == True deallocate, _ = user.post(res=models.Deallocate, data=post_deallocate) assert deallocate['startTime'] == post_deallocate['startTime'] @@ -762,7 +764,7 @@ def test_trade(action_model_state: Tuple[Type[models.Action], states.Trading], u action['invoiceNumber'] = 'ABC' action, _ = user.post(action, res=models.Action) assert action['devices'][0]['id'] == snapshot['device']['id'] - device, _ = user.get(res=Device, item=snapshot['device']['id']) + device, _ = user.get(res=Device, item=snapshot['device']['devicehubID']) assert device['actions'][-1]['id'] == action['id'] assert device['trading'] == state.name @@ -785,7 +787,7 @@ def test_price_custom(): assert p['price'] == 25.25 assert p['currency'] == Currency.EUR.name == 'EUR' - c, _ = client.get(res=Device, item=computer.id) + c, _ = client.get(res=Device, item=computer.devicehub_id) assert c['price']['id'] == p['id'] @@ -803,7 +805,7 @@ def test_price_custom_client(user: UserClient): assert 25 == price['price'] assert Currency.EUR.name == price['currency'] - device, _ = user.get(res=Device, item=price['device']['id']) + device, _ = user.get(res=Device, item=price['device']['devicehubID']) assert 25 == device['price']['price'] diff --git a/tests/test_device.py b/tests/test_device.py index 851698fb..7d8cc374 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -416,7 +416,9 @@ def test_get_device(app: Devicehub, user: UserClient): agent=Person(name='Timmy'), author=User(email='bar@bar.com'))) db.session.commit() - pc, _ = user.get(res=d.Device, item=1) + devicehub_id = pc.devicehub_id + + pc, _ = user.get(res=d.Device, item=devicehub_id) assert len(pc['actions']) == 1 assert pc['actions'][0]['type'] == 'TestConnectivity' assert pc['actions'][0]['device'] == 1 @@ -473,14 +475,14 @@ def test_get_device_permissions(app: Devicehub, user: UserClient, user2: UserCli """Checks GETting a d.Desktop with its components.""" s, _ = user.post(file('asus-eee-1000h.snapshot.11'), res=m.Snapshot) - pc, res = user.get(res=d.Device, item=s['device']['id']) + pc, res = user.get(res=d.Device, item=s['device']['devicehubID']) assert res.status_code == 200 assert len(pc['actions']) == 9 - html, _ = client.get(res=d.Device, item=s['device']['id'], accept=ANY) + html, _ = client.get(res=d.Device, item=s['device']['devicehubID'], accept=ANY) assert 'intel atom cpu n270 @ 1.60ghz' in html assert '00:24:8C:7F:CF:2D – 100 Mbps' in html - pc2, res2 = user2.get(res=d.Device, item=s['device']['id'], accept=ANY) + pc2, res2 = user2.get(res=d.Device, item=s['device']['devicehubID'], accept=ANY) assert res2.status_code == 200 assert pc2 == html @@ -555,7 +557,7 @@ def test_device_properties_format(app: Devicehub, user: UserClient): @pytest.mark.mvp def test_device_public(user: UserClient, client: Client): s, _ = user.post(file('asus-eee-1000h.snapshot.11'), res=m.Snapshot) - html, _ = client.get(res=d.Device, item=s['device']['id'], accept=ANY) + html, _ = client.get(res=d.Device, item=s['device']['devicehubID'], accept=ANY) assert 'intel atom cpu n270 @ 1.60ghz' in html assert '00:24:8C:7F:CF:2D – 100 Mbps' in html @@ -614,8 +616,8 @@ def test_cooking_mixer_api(user: UserClient): def test_hid_with_mac(app: Devicehub, user: UserClient): """Checks hid with mac.""" snapshot = file('asus-eee-1000h.snapshot.11') - user.post(snapshot, res=m.Snapshot) - pc, _ = user.get(res=d.Device, item=1) + snap, _ = user.post(snapshot, res=m.Snapshot) + pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID']) assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d' @@ -624,8 +626,8 @@ def test_hid_without_mac(app: Devicehub, user: UserClient): """Checks hid without mac.""" snapshot = file('asus-eee-1000h.snapshot.11') snapshot['components'] = [c for c in snapshot['components'] if c['type'] != 'NetworkAdapter'] - user.post(snapshot, res=m.Snapshot) - pc, _ = user.get(res=d.Device, item=1) + snap, _ = user.post(snapshot, res=m.Snapshot) + pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID']) assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116' @@ -635,8 +637,8 @@ def test_hid_with_mac_none(app: Devicehub, user: UserClient): snapshot = file('asus-eee-1000h.snapshot.11') network = [c for c in snapshot['components'] if c['type'] == 'NetworkAdapter'][0] network['serialNumber'] = None - user.post(snapshot, res=m.Snapshot) - pc, _ = user.get(res=d.Device, item=1) + snap, _ = user.post(snapshot, res=m.Snapshot) + pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID']) assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116' @@ -664,8 +666,8 @@ def test_hid_with_2network_and_drop_no_mac_in_hid(app: Devicehub, user: UserClie network2 = copy.copy(network) snapshot['components'].append(network2) network['serialNumber'] = 'a0:24:8c:7f:cf:2d' - user.post(snapshot, res=m.Snapshot) - pc, _ = user.get(res=d.Device, item=1) + snap, _ = user.post(snapshot, res=m.Snapshot) + pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID']) assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d' snapshot['uuid'] = 'd1b70cb8-8929-4f36-99b7-fe052cec0abb' @@ -687,8 +689,8 @@ def test_hid_with_2network_and_drop_mac_in_hid(app: Devicehub, user: UserClient) network2 = copy.copy(network) snapshot['components'].append(network2) network['serialNumber'] = 'a0:24:8c:7f:cf:2d' - user.post(snapshot, res=m.Snapshot) - pc, _ = user.get(res=d.Device, item=1) + snap, _ = user.post(snapshot, res=m.Snapshot) + pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID']) assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d' # we drop the network card then is used for to build the hid diff --git a/tests/test_documents.py b/tests/test_documents.py index 5ac747b5..b1446156 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -173,7 +173,7 @@ def test_live_export_csv2(user: UserClient, client: Client, app: Devicehub): assert "4692" in csv_user assert "8692" in csv_user - assert "SystemId" in csv_user + assert "DevicehubID" in csv_user @pytest.mark.mvp @pytest.mark.usefixtures(conftest.app_context.__name__) diff --git a/tests/test_lot.py b/tests/test_lot.py index 9c04b046..0d84a7fe 100644 --- a/tests/test_lot.py +++ b/tests/test_lot.py @@ -365,13 +365,14 @@ def test_lot_post_add_remove_device_view(app: Devicehub, user: UserClient): db.session.add(device) db.session.commit() device_id = device.id + devicehub_id = device.devicehub_id parent, _ = user.post(({'name': 'lot'}), res=Lot) lot, _ = user.post({}, res=Lot, item='{}/devices'.format(parent['id']), query=[('id', device_id)]) assert lot['devices'][0]['id'] == device_id, 'Lot contains device' - device, _ = user.get(res=Device, item=device_id) + device, _ = user.get(res=Device, item=devicehub_id) assert len(device['lots']) == 1 assert device['lots'][0]['id'] == lot['id'], 'Device is inside lot' diff --git a/tests/test_rate.py b/tests/test_rate.py index 6b5a25af..9420b5f7 100644 --- a/tests/test_rate.py +++ b/tests/test_rate.py @@ -39,7 +39,7 @@ def test_rate_with_multiple_visual_tests(user: UserClient): """ s = file('real-hp.snapshot.11') snapshot, _ = user.post(s, res=Snapshot) - device, _ = user.get(res=Device, item=snapshot['device']['id']) + device, _ = user.get(res=Device, item=snapshot['device']['devicehubID']) visual_test = next(e for e in reversed(device['actions']) if e['type'] == VisualTest.t) assert visual_test['appearanceRange'] == 'B' @@ -53,7 +53,7 @@ def test_rate_with_multiple_visual_tests(user: UserClient): 'appearanceRange': 'A', 'functionalityRange': 'A' }, res=Action) - device, _ = user.get(res=Device, item=snapshot['device']['id']) + device, _ = user.get(res=Device, item=snapshot['device']['devicehubID']) visual_test = next(e for e in reversed(device['actions']) if e['type'] == VisualTest.t) assert visual_test['appearanceRange'] == 'A' diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index a653e95b..cd4d8b2c 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -92,7 +92,7 @@ def test_snapshot_post(user: UserClient): assert snapshot['author']['id'] == user.user['id'] assert 'actions' not in snapshot['device'] assert 'author' not in snapshot['device'] - device, _ = user.get(res=m.Device, item=snapshot['device']['id']) + device, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID']) key = itemgetter('serialNumber') snapshot['components'].sort(key=key) device['components'].sort(key=key) @@ -140,8 +140,8 @@ def test_snapshot_update_timefield_updated(user: UserClient): computer2 = file('2-second-device-with-components-of-first.snapshot') snapshot_and_check(user, computer2, action_types=('Remove', 'RateComputer'), perform_second_snapshot=False) - pc1_id = snapshot['device']['id'] - pc1, _ = user.get(res=m.Device, item=pc1_id) + pc1_devicehub_id = snapshot['device']['devicehubID'] + pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id) assert pc1['updated'] != snapshot['device']['updated'] @@ -170,7 +170,8 @@ def test_snapshot_component_add_remove(user: UserClient): RateComputer.t), perform_second_snapshot=False) pc1_id = snapshot1['device']['id'] - pc1, _ = user.get(res=m.Device, item=pc1_id) + pc1_devicehub_id = snapshot1['device']['devicehubID'] + pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id) update1_pc1 = pc1['updated'] # Parent contains components assert tuple(c['serialNumber'] for c in pc1['components']) == ('p1c1s', 'p1c2s', 'p1c3s') @@ -180,7 +181,7 @@ def test_snapshot_component_add_remove(user: UserClient): assert len(pc1['actions']) == 3 assert pc1['actions'][1]['type'] == Snapshot.t # p1c1s has Snapshot - p1c1s, _ = user.get(res=m.Device, item=pc1['components'][0]['id']) + p1c1s, _ = user.get(res=m.Device, item=pc1['components'][0]['devicehubID']) assert tuple(e['type'] for e in p1c1s['actions']) == ('Snapshot', 'RateComputer') # We register a new device @@ -192,8 +193,9 @@ def test_snapshot_component_add_remove(user: UserClient): snapshot2 = snapshot_and_check(user, s2, action_types=('Remove', 'RateComputer'), perform_second_snapshot=False) pc2_id = snapshot2['device']['id'] - pc1, _ = user.get(res=m.Device, item=pc1_id) - pc2, _ = user.get(res=m.Device, item=pc2_id) + pc2_devicehub_id = snapshot2['device']['devicehubID'] + pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id) + pc2, _ = user.get(res=m.Device, item=pc2_devicehub_id) # Check if the update_timestamp is updated update1_pc2 = pc2['updated'] update2_pc1 = pc1['updated'] @@ -207,7 +209,7 @@ def test_snapshot_component_add_remove(user: UserClient): assert all(c['parent'] == pc2_id for c in pc2['components']) assert tuple(e['type'] for e in pc2['actions']) == ('Snapshot', 'RateComputer') # p1c2s has two Snapshots, a Remove and an Add - p1c2s, _ = user.get(res=m.Device, item=pc2['components'][0]['id']) + p1c2s, _ = user.get(res=m.Device, item=pc2['components'][0]['devicehubID']) assert tuple(e['type'] for e in p1c2s['actions']) == ( 'BenchmarkProcessor', 'Snapshot', 'RateComputer', 'Snapshot', 'Remove', 'RateComputer' ) @@ -218,8 +220,8 @@ def test_snapshot_component_add_remove(user: UserClient): # PC 0: p1c2s, p1c3s. PC 1: p2c1s s3 = file('3-first-device-but-removing-motherboard-and-adding-processor-from-2.snapshot') snapshot_and_check(user, s3, ('Remove', 'RateComputer'), perform_second_snapshot=False) - pc1, _ = user.get(res=m.Device, item=pc1_id) - pc2, _ = user.get(res=m.Device, item=pc2_id) + pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id) + pc2, _ = user.get(res=m.Device, item=pc2_devicehub_id) # Check if the update_timestamp is updated update2_pc2 = pc2['updated'] update3_pc1 = pc1['updated'] @@ -247,7 +249,7 @@ def test_snapshot_component_add_remove(user: UserClient): 'Remove' # the processor we added in 2. ) # p1c2s has Snapshot, Remove and Add - p1c2s, _ = user.get(res=m.Device, item=pc1['components'][0]['id']) + p1c2s, _ = user.get(res=m.Device, item=pc1['components'][0]['devicehubID']) assert tuple(get_actions_info(p1c2s['actions'])) == ( ('BenchmarkProcessor', []), # first BenchmarkProcessor ('Snapshot', ['p1c1s', 'p1c2s', 'p1c3s']), # First Snapshot to PC1 @@ -264,8 +266,8 @@ def test_snapshot_component_add_remove(user: UserClient): # adding a graphic card and adding a new component s4 = file('4-first-device-but-removing-processor.snapshot-and-adding-graphic-card') snapshot4 = snapshot_and_check(user, s4, ('RateComputer',), perform_second_snapshot=False) - pc1, _ = user.get(res=m.Device, item=pc1_id) - pc2, _ = user.get(res=m.Device, item=pc2_id) + pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id) + pc2, _ = user.get(res=m.Device, item=pc2_devicehub_id) # Check if the update_timestamp is updated update3_pc2 = pc2['updated'] update4_pc1 = pc1['updated'] @@ -429,7 +431,7 @@ def test_erase_privacy_standards_endtime_sort(user: UserClient): # The actual test storage = next(e for e in snapshot['components'] if e['type'] == SolidStateDrive.t) - storage, _ = user.get(res=m.Device, item=storage['id']) # Let's get storage actions too + storage, _ = user.get(res=m.Device, item=storage['devicehubID']) # Let's get storage actions too # order: endTime ascending # erasure1/2 have an user defined time and others actions endTime = created erasure1, erasure2, benchmark_hdd1, _snapshot1, _, _, benchmark_hdd2, _snapshot2 = storage['actions'][:8] @@ -455,17 +457,17 @@ def test_erase_privacy_standards_endtime_sort(user: UserClient): assert 'num' not in step2 assert ['HMG_IS5'] == erasure['standards'] assert storage['privacy']['type'] == 'EraseSectors' - pc, _ = user.get(res=m.Device, item=snapshot['device']['id']) + pc, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID']) assert pc['privacy'] == [storage['privacy']] # Let's try a second erasure with an error s['uuid'] = uuid4() s['components'][0]['actions'][0]['severity'] = 'Error' snapshot, _ = user.post(s, res=Snapshot) - storage, _ = user.get(res=m.Device, item=storage['id']) + storage, _ = user.get(res=m.Device, item=storage['devicehubID']) assert storage['hid'] == 'solidstatedrive-c1mr-c1ml-c1s' assert storage['privacy']['type'] == 'EraseSectors' - pc, _ = user.get(res=m.Device, item=snapshot['device']['id']) + pc, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID']) assert pc['privacy'] == [storage['privacy']] @@ -780,7 +782,7 @@ def test_snapshot_failed_end_time_bug(app: Devicehub, user: UserClient): """ snapshot_file = file('asus-end_time_bug88.snapshot') snapshot, _ = user.post(res=Snapshot, data=snapshot_file) - device, _ = user.get(res=m.Device, item=snapshot['device']['id']) + device, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID']) end_times = [x['endTime'] for x in device['actions']] assert '1970-01-02T00:00:00+00:00' in end_times @@ -797,7 +799,7 @@ def test_snapshot_not_failed_end_time_bug(app: Devicehub, user: UserClient): snapshot_file = file('asus-end_time_bug88.snapshot') snapshot_file['endTime'] = '2001-01-01 00:00:00+00:00' snapshot, _ = user.post(res=Snapshot, data=snapshot_file) - device, _ = user.get(res=m.Device, item=snapshot['device']['id']) + device, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID']) end_times = [x['endTime'] for x in device['actions']] assert not '1970-01-02T00:00:00+00:00' in end_times @@ -831,7 +833,7 @@ def test_snapshot_mobil(app: Devicehub, user: UserClient): """ snapshot_file = file('mobil') snapshot, _ = user.post(res=Snapshot, data=snapshot_file) - device, _ = user.get(res=m.Device, item=snapshot['device']['id']) + device, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID']) tmp_snapshots = app.config['TMP_SNAPSHOTS'] shutil.rmtree(tmp_snapshots) diff --git a/tests/test_tag.py b/tests/test_tag.py index b0336021..81574ed7 100644 --- a/tests/test_tag.py +++ b/tests/test_tag.py @@ -183,8 +183,9 @@ def test_tag_manual_link_search(app: Devicehub, user: UserClient): db.session.add(desktop) db.session.commit() desktop_id = desktop.id + devicehub_id = desktop.devicehub_id user.put({}, res=Tag, item='foo-bar/device/{}'.format(desktop_id), status=204) - device, _ = user.get(res=Device, item=1) + device, _ = user.get(res=Device, item=devicehub_id) assert device['tags'][0]['id'] == 'foo-bar' # Device already linked @@ -224,7 +225,7 @@ def test_tag_secondary_workbench_link_find(user: UserClient): s = file('basic.snapshot') s['device']['tags'] = [{'id': 'foo', 'secondary': 'bar', 'type': 'Tag'}] snapshot, _ = user.post(s, res=Snapshot) - device, _ = user.get(res=Device, item=snapshot['device']['id']) + device, _ = user.get(res=Device, item=snapshot['device']['devicehubID']) assert device['tags'][0]['id'] == 'foo' assert device['tags'][0]['secondary'] == 'bar' diff --git a/tests/test_workbench.py b/tests/test_workbench.py index e2d5ce9a..3a38b1ae 100644 --- a/tests/test_workbench.py +++ b/tests/test_workbench.py @@ -49,7 +49,7 @@ def test_workbench_server_condensed(user: UserClient): } assert snapshot['closed'] assert snapshot['severity'] == 'Info' - device, _ = user.get(res=Device, item=snapshot['device']['id']) + device, _ = user.get(res=Device, item=snapshot['device']['devicehubID']) assert device['dataStorageSize'] == 1100 assert device['chassis'] == 'Tower' assert device['hid'] == 'desktop-d1mr-d1ml-d1s-na1-s' @@ -129,7 +129,7 @@ def test_workbench_server_phases(user: UserClient): assert snapshot['closed'] assert snapshot['severity'] == 'Info' - pc, _ = user.get(res=Device, item=snapshot['id']) + pc, _ = user.get(res=Device, item=snapshot['devicehubID']) assert len(pc['actions']) == 10 # todo shall I add child actions? @@ -173,7 +173,7 @@ def test_snapshot_real_eee_1001pxd_with_rate(user: UserClient): """ s = file('real-eee-1001pxd.snapshot.11') snapshot, _ = user.post(res=em.Snapshot, data=s) - pc, _ = user.get(res=Device, item=snapshot['device']['id']) + pc, _ = user.get(res=Device, item=snapshot['device']['devicehubID']) assert pc['type'] == 'Laptop' assert pc['chassis'] == 'Netbook' assert pc['model'] == '1001pxd' @@ -213,7 +213,7 @@ def test_snapshot_real_eee_1001pxd_with_rate(user: UserClient): assert cpu['speed'] == 1.667 assert 'hid' not in cpu assert pc['processorModel'] == cpu['model'] == 'intel atom cpu n455 @ 1.66ghz' - cpu, _ = user.get(res=Device, item=cpu['id']) + cpu, _ = user.get(res=Device, item=cpu['devicehubID']) actions = cpu['actions'] sysbench = next(e for e in actions if e['type'] == em.BenchmarkProcessorSysbench.t) assert sysbench['elapsed'] == 164 @@ -233,7 +233,7 @@ def test_snapshot_real_eee_1001pxd_with_rate(user: UserClient): assert gpu['model'] == 'atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller' assert gpu['manufacturer'] == 'intel corporation' assert gpu['memory'] == 256 - gpu, _ = user.get(res=Device, item=gpu['id']) + gpu, _ = user.get(res=Device, item=gpu['devicehubID']) action_types = tuple(e['type'] for e in gpu['actions']) assert em.BenchmarkRamSysbench.t in action_types assert em.StressTest.t in action_types @@ -252,7 +252,7 @@ def test_snapshot_real_eee_1001pxd_with_rate(user: UserClient): assert hdd['hid'] == 'harddrive-hitachi-hts54322-e2024242cv86hj' assert hdd['interface'] == 'ATA' assert hdd['size'] == 238475 - hdd, _ = user.get(res=Device, item=hdd['id']) + hdd, _ = user.get(res=Device, item=hdd['devicehubID']) action_types = tuple(e['type'] for e in hdd['actions']) assert em.BenchmarkRamSysbench.t in action_types assert em.StressTest.t in action_types From 2b60af8b08032bac1bfac7cd7a7d2c6d308a30d0 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 9 Mar 2021 12:54:57 +0100 Subject: [PATCH 12/16] fixing tests and property url of device --- ereuse_devicehub/resources/device/models.py | 2 +- ereuse_devicehub/resources/tag/view.py | 4 ++-- tests/files/basic.csv | 2 +- tests/files/proposal_extended_csv_report.csv | 4 ++-- tests/test_device_find.py | 4 ++-- tests/test_documents.py | 2 +- tests/test_snapshot.py | 15 +++++++-------- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index a5376ae4..bf43a356 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -236,7 +236,7 @@ class Device(Thing): @property def url(self) -> urlutils.URL: """The URL where to GET this device.""" - return urlutils.URL(url_for_resource(Device, item_id=self.id)) + return urlutils.URL(url_for_resource(Device, item_id=self.devicehub_id)) @property def rate(self): diff --git a/ereuse_devicehub/resources/tag/view.py b/ereuse_devicehub/resources/tag/view.py index 0aab1612..9f349bb1 100644 --- a/ereuse_devicehub/resources/tag/view.py +++ b/ereuse_devicehub/resources/tag/view.py @@ -62,7 +62,7 @@ class TagDeviceView(View): if not tag.device: raise TagNotLinked(tag.id) if not request.authorization: - return redirect(location=url_for_resource(Device, tag.device.id)) + return redirect(location=url_for_resource(Device, tag.device.devicehub_id)) return app.resources[Device.t].schema.jsonify(tag.device) # noinspection PyMethodOverriding @@ -93,7 +93,7 @@ def get_device_from_tag(id: str): # todo this could be more efficient by Device.query... join with tag device = Tag.query.filter_by(id=id).one().device if not request.authorization: - return redirect(location=url_for_resource(Device, device.id)) + return redirect(location=url_for_resource(Device, device.devicehub_id)) if device is None: raise TagNotLinked(id) return app.resources[Device.t].schema.jsonify(device) diff --git a/tests/files/basic.csv b/tests/files/basic.csv index 0583518a..a5370449 100644 --- a/tests/files/basic.csv +++ b/tests/files/basic.csv @@ -1,2 +1,2 @@ DevicehubID;DocumentID;Public Link;Tag 1 Type;Tag 1 ID;Tag 1 Organization;Tag 2 Type;Tag 2 ID;Tag 2 Organization;Tag 3 Type;Tag 3 ID;Tag 3 Organization;Device Hardware ID;Device Type;Device Chassis;Device Serial Number;Device Model;Device Manufacturer;Registered in;Registered (process);Updated in (software);Updated in (web);Physical state;Trading state;Processor;RAM (MB);Data Storage Size (MB);Processor 1;Processor 1 Manufacturer;Processor 1 Model;Processor 1 Serial Number;Processor 1 Number of cores;Processor 1 Speed (GHz);Benchmark Processor 1 (points);Benchmark ProcessorSysbench Processor 1 (points);Processor 2;Processor 2 Manufacturer;Processor 2 Model;Processor 2 Serial Number;Processor 2 Number of cores;Processor 2 Speed (GHz);Benchmark Processor 2 (points);Benchmark ProcessorSysbench Processor 2 (points);RamModule 1;RamModule 1 Manufacturer;RamModule 1 Model;RamModule 1 Serial Number;RamModule 1 Size (MB);RamModule 1 Speed (MHz);RamModule 2;RamModule 2 Manufacturer;RamModule 2 Model;RamModule 2 Serial Number;RamModule 2 Size (MB);RamModule 2 Speed (MHz);RamModule 3;RamModule 3 Manufacturer;RamModule 3 Model;RamModule 3 Serial Number;RamModule 3 Size (MB);RamModule 3 Speed (MHz);RamModule 4;RamModule 4 Manufacturer;RamModule 4 Model;RamModule 4 Serial Number;RamModule 4 Size (MB);RamModule 4 Speed (MHz);DataStorage 1;DataStorage 1 Manufacturer;DataStorage 1 Model;DataStorage 1 Serial Number;DataStorage 1 Size (MB);Erasure DataStorage 1;Erasure DataStorage 1 Serial Number;Erasure DataStorage 1 Size (MB);Erasure DataStorage 1 Software;Erasure DataStorage 1 Result;Erasure DataStorage 1 Type;Erasure DataStorage 1 Method;Erasure DataStorage 1 Elapsed (hours);Erasure DataStorage 1 Date;Erasure DataStorage 1 Steps;Erasure DataStorage 1 Steps Start Time;Erasure DataStorage 1 Steps End Time;Benchmark DataStorage 1 Read Speed (MB/s);Benchmark DataStorage 1 Writing speed (MB/s);Test DataStorage 1 Software;Test DataStorage 1 Type;Test DataStorage 1 Result;Test DataStorage 1 Power on (hours used);Test DataStorage 1 Lifetime remaining (percentage);DataStorage 2;DataStorage 2 Manufacturer;DataStorage 2 Model;DataStorage 2 Serial Number;DataStorage 2 Size (MB);Erasure DataStorage 2;Erasure DataStorage 2 Serial Number;Erasure DataStorage 2 Size (MB);Erasure DataStorage 2 Software;Erasure DataStorage 2 Result;Erasure DataStorage 2 Type;Erasure DataStorage 2 Method;Erasure DataStorage 2 Elapsed (hours);Erasure DataStorage 2 Date;Erasure DataStorage 2 Steps;Erasure DataStorage 2 Steps Start Time;Erasure DataStorage 2 Steps End Time;Benchmark DataStorage 2 Read Speed (MB/s);Benchmark DataStorage 2 Writing speed (MB/s);Test DataStorage 2 Software;Test DataStorage 2 Type;Test DataStorage 2 Result;Test DataStorage 2 Power on (hours used);Test DataStorage 2 Lifetime remaining (percentage);DataStorage 3;DataStorage 3 Manufacturer;DataStorage 3 Model;DataStorage 3 Serial Number;DataStorage 3 Size (MB);Erasure DataStorage 3;Erasure DataStorage 3 Serial Number;Erasure DataStorage 3 Size (MB);Erasure DataStorage 3 Software;Erasure DataStorage 3 Result;Erasure DataStorage 3 Type;Erasure DataStorage 3 Method;Erasure DataStorage 3 Elapsed (hours);Erasure DataStorage 3 Date;Erasure DataStorage 3 Steps;Erasure DataStorage 3 Steps Start Time;Erasure DataStorage 3 Steps End Time;Benchmark DataStorage 3 Read Speed (MB/s);Benchmark DataStorage 3 Writing speed (MB/s);Test DataStorage 3 Software;Test DataStorage 3 Type;Test DataStorage 3 Result;Test DataStorage 3 Power on (hours used);Test DataStorage 3 Lifetime remaining (percentage);DataStorage 4;DataStorage 4 Manufacturer;DataStorage 4 Model;DataStorage 4 Serial Number;DataStorage 4 Size (MB);Erasure DataStorage 4;Erasure DataStorage 4 Serial Number;Erasure DataStorage 4 Size (MB);Erasure DataStorage 4 Software;Erasure DataStorage 4 Result;Erasure DataStorage 4 Type;Erasure DataStorage 4 Method;Erasure DataStorage 4 Elapsed (hours);Erasure DataStorage 4 Date;Erasure DataStorage 4 Steps;Erasure DataStorage 4 Steps Start Time;Erasure DataStorage 4 Steps End Time;Benchmark DataStorage 4 Read Speed (MB/s);Benchmark DataStorage 4 Writing speed (MB/s);Test DataStorage 4 Software;Test DataStorage 4 Type;Test DataStorage 4 Result;Test DataStorage 4 Power on (hours used);Test DataStorage 4 Lifetime remaining (percentage);Motherboard 1;Motherboard 1 Manufacturer;Motherboard 1 Model;Motherboard 1 Serial Number;Display 1;Display 1 Manufacturer;Display 1 Model;Display 1 Serial Number;GraphicCard 1;GraphicCard 1 Manufacturer;GraphicCard 1 Model;GraphicCard 1 Serial Number;GraphicCard 1 Memory (MB);GraphicCard 2;GraphicCard 2 Manufacturer;GraphicCard 2 Model;GraphicCard 2 Serial Number;GraphicCard 2 Memory (MB);NetworkAdapter 1;NetworkAdapter 1 Manufacturer;NetworkAdapter 1 Model;NetworkAdapter 1 Serial Number;NetworkAdapter 2;NetworkAdapter 2 Manufacturer;NetworkAdapter 2 Model;NetworkAdapter 2 Serial Number;SoundCard 1;SoundCard 1 Manufacturer;SoundCard 1 Model;SoundCard 1 Serial Number;SoundCard 2;SoundCard 2 Manufacturer;SoundCard 2 Model;SoundCard 2 Serial Number;Device Rate;Device Range;Processor Rate;Processor Range;RAM Rate;RAM Range;Data Storage Rate;Data Storage Range;Price;Benchmark RamSysbench (points) -LE94J;;http://localhost/devices/LE94J;;;;;;;;;;desktop-d1mr-d1ml-d1s;Desktop;Microtower;d1s;d1ml;d1mr;Thu Oct 22 15:36:47 2020;Workbench 11.0;2020-10-22 15:36:47.814316+02:00;;;;p1ml;0;0;Processor 4: model p1ml, S/N p1s;p1mr;p1ml;p1s;;1.6;2410.0;;;;;;;;;;RamModule 3: model rm1ml, S/N rm1s;rm1mr;rm1ml;rm1s;;1333;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GraphicCard 2: model gc1ml, S/N gc1s;gc1mr;gc1ml;gc1s;;;;;;;;;;;;;;;;;;;;;;;1.0;VERY_LOW;1.0;VERY_LOW;1.0;VERY_LOW;1.0;VERY_LOW;; +93652;;http://localhost/devices/93652;;;;;;;;;;desktop-d1mr-d1ml-d1s;Desktop;Microtower;d1s;d1ml;d1mr;Thu Oct 22 15:36:47 2020;Workbench 11.0;2020-10-22 15:36:47.814316+02:00;;;;p1ml;0;0;Processor 4: model p1ml, S/N p1s;p1mr;p1ml;p1s;;1.6;2410.0;;;;;;;;;;RamModule 3: model rm1ml, S/N rm1s;rm1mr;rm1ml;rm1s;;1333;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GraphicCard 2: model gc1ml, S/N gc1s;gc1mr;gc1ml;gc1s;;;;;;;;;;;;;;;;;;;;;;;1.0;VERY_LOW;1.0;VERY_LOW;1.0;VERY_LOW;1.0;VERY_LOW;; diff --git a/tests/files/proposal_extended_csv_report.csv b/tests/files/proposal_extended_csv_report.csv index 6a27c461..0e7ad8c0 100644 --- a/tests/files/proposal_extended_csv_report.csv +++ b/tests/files/proposal_extended_csv_report.csv @@ -1,3 +1,3 @@ DevicehubID;DocumentID;Public Link;Tag 1 Type;Tag 1 ID;Tag 1 Organization;Tag 2 Type;Tag 2 ID;Tag 2 Organization;Tag 3 Type;Tag 3 ID;Tag 3 Organization;Device Hardware ID;Device Type;Device Chassis;Device Serial Number;Device Model;Device Manufacturer;Registered in;Registered (process);Updated in (software);Updated in (web);Physical state;Trading state;Processor;RAM (MB);Data Storage Size (MB);Processor 1;Processor 1 Manufacturer;Processor 1 Model;Processor 1 Serial Number;Processor 1 Number of cores;Processor 1 Speed (GHz);Benchmark Processor 1 (points);Benchmark ProcessorSysbench Processor 1 (points);Processor 2;Processor 2 Manufacturer;Processor 2 Model;Processor 2 Serial Number;Processor 2 Number of cores;Processor 2 Speed (GHz);Benchmark Processor 2 (points);Benchmark ProcessorSysbench Processor 2 (points);RamModule 1;RamModule 1 Manufacturer;RamModule 1 Model;RamModule 1 Serial Number;RamModule 1 Size (MB);RamModule 1 Speed (MHz);RamModule 2;RamModule 2 Manufacturer;RamModule 2 Model;RamModule 2 Serial Number;RamModule 2 Size (MB);RamModule 2 Speed (MHz);RamModule 3;RamModule 3 Manufacturer;RamModule 3 Model;RamModule 3 Serial Number;RamModule 3 Size (MB);RamModule 3 Speed (MHz);RamModule 4;RamModule 4 Manufacturer;RamModule 4 Model;RamModule 4 Serial Number;RamModule 4 Size (MB);RamModule 4 Speed (MHz);DataStorage 1;DataStorage 1 Manufacturer;DataStorage 1 Model;DataStorage 1 Serial Number;DataStorage 1 Size (MB);Erasure DataStorage 1;Erasure DataStorage 1 Serial Number;Erasure DataStorage 1 Size (MB);Erasure DataStorage 1 Software;Erasure DataStorage 1 Result;Erasure DataStorage 1 Type;Erasure DataStorage 1 Method;Erasure DataStorage 1 Elapsed (hours);Erasure DataStorage 1 Date;Erasure DataStorage 1 Steps;Erasure DataStorage 1 Steps Start Time;Erasure DataStorage 1 Steps End Time;Benchmark DataStorage 1 Read Speed (MB/s);Benchmark DataStorage 1 Writing speed (MB/s);Test DataStorage 1 Software;Test DataStorage 1 Type;Test DataStorage 1 Result;Test DataStorage 1 Power on (hours used);Test DataStorage 1 Lifetime remaining (percentage);DataStorage 2;DataStorage 2 Manufacturer;DataStorage 2 Model;DataStorage 2 Serial Number;DataStorage 2 Size (MB);Erasure DataStorage 2;Erasure DataStorage 2 Serial Number;Erasure DataStorage 2 Size (MB);Erasure DataStorage 2 Software;Erasure DataStorage 2 Result;Erasure DataStorage 2 Type;Erasure DataStorage 2 Method;Erasure DataStorage 2 Elapsed (hours);Erasure DataStorage 2 Date;Erasure DataStorage 2 Steps;Erasure DataStorage 2 Steps Start Time;Erasure DataStorage 2 Steps End Time;Benchmark DataStorage 2 Read Speed (MB/s);Benchmark DataStorage 2 Writing speed (MB/s);Test DataStorage 2 Software;Test DataStorage 2 Type;Test DataStorage 2 Result;Test DataStorage 2 Power on (hours used);Test DataStorage 2 Lifetime remaining (percentage);DataStorage 3;DataStorage 3 Manufacturer;DataStorage 3 Model;DataStorage 3 Serial Number;DataStorage 3 Size (MB);Erasure DataStorage 3;Erasure DataStorage 3 Serial Number;Erasure DataStorage 3 Size (MB);Erasure DataStorage 3 Software;Erasure DataStorage 3 Result;Erasure DataStorage 3 Type;Erasure DataStorage 3 Method;Erasure DataStorage 3 Elapsed (hours);Erasure DataStorage 3 Date;Erasure DataStorage 3 Steps;Erasure DataStorage 3 Steps Start Time;Erasure DataStorage 3 Steps End Time;Benchmark DataStorage 3 Read Speed (MB/s);Benchmark DataStorage 3 Writing speed (MB/s);Test DataStorage 3 Software;Test DataStorage 3 Type;Test DataStorage 3 Result;Test DataStorage 3 Power on (hours used);Test DataStorage 3 Lifetime remaining (percentage);DataStorage 4;DataStorage 4 Manufacturer;DataStorage 4 Model;DataStorage 4 Serial Number;DataStorage 4 Size (MB);Erasure DataStorage 4;Erasure DataStorage 4 Serial Number;Erasure DataStorage 4 Size (MB);Erasure DataStorage 4 Software;Erasure DataStorage 4 Result;Erasure DataStorage 4 Type;Erasure DataStorage 4 Method;Erasure DataStorage 4 Elapsed (hours);Erasure DataStorage 4 Date;Erasure DataStorage 4 Steps;Erasure DataStorage 4 Steps Start Time;Erasure DataStorage 4 Steps End Time;Benchmark DataStorage 4 Read Speed (MB/s);Benchmark DataStorage 4 Writing speed (MB/s);Test DataStorage 4 Software;Test DataStorage 4 Type;Test DataStorage 4 Result;Test DataStorage 4 Power on (hours used);Test DataStorage 4 Lifetime remaining (percentage);Motherboard 1;Motherboard 1 Manufacturer;Motherboard 1 Model;Motherboard 1 Serial Number;Display 1;Display 1 Manufacturer;Display 1 Model;Display 1 Serial Number;GraphicCard 1;GraphicCard 1 Manufacturer;GraphicCard 1 Model;GraphicCard 1 Serial Number;GraphicCard 1 Memory (MB);GraphicCard 2;GraphicCard 2 Manufacturer;GraphicCard 2 Model;GraphicCard 2 Serial Number;GraphicCard 2 Memory (MB);NetworkAdapter 1;NetworkAdapter 1 Manufacturer;NetworkAdapter 1 Model;NetworkAdapter 1 Serial Number;NetworkAdapter 2;NetworkAdapter 2 Manufacturer;NetworkAdapter 2 Model;NetworkAdapter 2 Serial Number;SoundCard 1;SoundCard 1 Manufacturer;SoundCard 1 Model;SoundCard 1 Serial Number;SoundCard 2;SoundCard 2 Manufacturer;SoundCard 2 Model;SoundCard 2 Serial Number;Device Rate;Device Range;Processor Rate;Processor Range;RAM Rate;RAM Range;Data Storage Rate;Data Storage Range;Price;Benchmark RamSysbench (points) -LE94J;;http://localhost/devices/LE94J;unamed;foo;FooOrg;;;;;;;laptop-asustek_computer_inc-1001pxd-b8oaas048285-14:da:e9:42:f6:7b;Laptop;Netbook;b8oaas048285;1001pxd;asustek computer inc.;Thu Nov 12 19:53:01 2020;Workbench 11.0a2;2020-11-12 19:54:03.959185+01:00;;;;intel atom cpu n455 @ 2.66ghz;1024;238475;Processor 4: model intel atom cpu n455 @ 2.66ghz, S/N None;intel corp.;intel atom cpu n455 @ 2.66ghz;;1;2.667;6666.24;164.0803;;;;;;;;;RamModule 8: model None, S/N None;;;;1024;667;;;;;;;;;;;;;;;;;;;HardDrive 9: model hts54322, S/N e2024242cv86mm;hitachi;hts54322;e2024242cv86mm;238475;harddrive-hitachi-hts54322-e2024242cv86mm;e2024242cv86mm;238475;Workbench 11.0a2;Success;EraseBasic;Shred;1:16:49;2020-11-12 19:53:01.899092+01:00;✓ – StepRandom 1:16:49;2018-07-03 11:15:22.257059+02:00;2018-07-03 12:32:11.843190+02:00;66.2;21.8;Workbench 11.0a2;Short;Failure;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Motherboard 10: model 1001pxd, S/N eee0123456720;asustek computer inc.;1001pxd;eee0123456720;;;;;GraphicCard 5: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None;intel corporation;atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller;;256;;;;;;NetworkAdapter 2: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c9;qualcomm atheros;ar9285 wireless network adapter;74:2f:68:8b:fd:c9;NetworkAdapter 3: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7b;qualcomm atheros;ar8152 v2.0 fast ethernet;14:da:e9:42:f6:7b;SoundCard 6: model nm10/ich7 family high definition audio controller, S/N None;intel corporation;nm10/ich7 family high definition audio controller;;;;;;1.75;LOW;1.55;LOW;1.53;LOW;3.76;HIGH;52.50 €;15.7188 -XE5XZ;;http://localhost/devices/XE5XZ;;;;;;;;;;laptop-asustek_computer_inc-1001pxd-b8oaas048287-14:da:e9:42:f6:7c;Laptop;Netbook;b8oaas048287;1001pxd;asustek computer inc.;Thu Nov 12 19:53:02 2020;Workbench 11.0b11;2020-11-12 19:53:02.225373+01:00;;;;intel atom cpu n455 @ 1.66ghz;2048;558558;Processor 15: model intel atom cpu n455 @ 1.66ghz, S/N None;intel corp.;intel atom cpu n455 @ 1.66ghz;;1;1.667;6666.24;164.0803;;;;;;;;;RamModule 18: model None, S/N None;;;;1024;667;RamModule 19: model 48594d503131325336344350362d53362020, S/N 4f43487b;hynix semiconductor;48594d503131325336344350362d53362020;4f43487b;1024;667;;;;;;;;;;;;;HardDrive 20: model hts54322, S/N e2024242cv86hj;hitachi;hts54322;e2024242cv86hj;238475;harddrive-hitachi-hts54322-e2024242cv86hj;e2024242cv86hj;238475;Workbench 11.0b11;Success;EraseBasic;Shred;1:16:49;2020-11-12 19:53:02.175189+01:00;✓ – StepRandom 1:16:49;2018-07-03 11:15:22.257059+02:00;2018-07-03 12:32:11.843190+02:00;66.2;21.8;Workbench 11.0b11;Extended;Failure;;;DataStorage 21: model wdc wd1600bevt-2, S/N wd-wx11a80w7430;western digital;wdc wd1600bevt-2;wd-wx11a80w7430;160041;datastorage-western_digital-wdc_wd1600bevt-2-wd-wx11a80w7430;wd-wx11a80w7430;160041;Workbench 11.0b11;Failure;EraseBasic;Shred;0:45:36;2020-11-12 19:53:02.176882+01:00;✓ – StepRandom 0:45:36;2019-10-23 09:49:54.410830+02:00;2019-10-23 10:35:31.400587+02:00;41.6;17.3;Workbench 11.0b11;Short;Success;5293;195 days, 12:00:00;SolidStateDrive 22: model wdc wd1600bevt-2, S/N wd-wx11a80w7430;western digital;wdc wd1600bevt-2;wd-wx11a80w7430;160042;solidstatedrive-western_digital-wdc_wd1600bevt-2-wd-wx11a80w7430;wd-wx11a80w7430;160042;Workbench 11.0b11;Success;EraseSectors;Badblocks;1:46:03;2020-11-12 19:53:02.180043+01:00;✓ – StepRandom 0:46:03,✓ – StepZero 1:00:00;2019-08-19 18:48:19.690458+02:00,2019-08-19 19:34:22.690458+02:00;2019-08-19 19:34:22.930562+02:00,2019-08-19 20:34:22.930562+02:00;41.1;17.1;Workbench 11.0b11;Short;Success;5231;194 days, 17:00:00;;;;;;;;;;;;;;;;;;;;;;;;;Motherboard 23: model 1001pxd, S/N eee0123456789;asustek computer inc.;1001pxd;eee0123456789;;"auo ""auo""";auo lcd monitor;;GraphicCard 16: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None;intel corporation;atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller;;256;;;;;;NetworkAdapter 13: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c8;qualcomm atheros;ar9285 wireless network adapter;74:2f:68:8b:fd:c8;NetworkAdapter 14: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7c;qualcomm atheros;ar8152 v2.0 fast ethernet;14:da:e9:42:f6:7c;SoundCard 7: model usb 2.0 uvc vga webcam, S/N 0x0001;azurewave;usb 2.0 uvc vga webcam;0x0001;SoundCard 17: model nm10/ich7 family high definition audio controller, S/N None;intel corporation;nm10/ich7 family high definition audio controller;;1.72;LOW;1.31;LOW;1.99;LOW;3.97;HIGH;51.60 €;15.7188 +93652;;http://localhost/devices/93652;unamed;foo;FooOrg;;;;;;;laptop-asustek_computer_inc-1001pxd-b8oaas048285-14:da:e9:42:f6:7b;Laptop;Netbook;b8oaas048285;1001pxd;asustek computer inc.;Thu Nov 12 19:53:01 2020;Workbench 11.0a2;2020-11-12 19:54:03.959185+01:00;;;;intel atom cpu n455 @ 2.66ghz;1024;238475;Processor 4: model intel atom cpu n455 @ 2.66ghz, S/N None;intel corp.;intel atom cpu n455 @ 2.66ghz;;1;2.667;6666.24;164.0803;;;;;;;;;RamModule 8: model None, S/N None;;;;1024;667;;;;;;;;;;;;;;;;;;;HardDrive 9: model hts54322, S/N e2024242cv86mm;hitachi;hts54322;e2024242cv86mm;238475;harddrive-hitachi-hts54322-e2024242cv86mm;e2024242cv86mm;238475;Workbench 11.0a2;Success;EraseBasic;Shred;1:16:49;2020-11-12 19:53:01.899092+01:00;✓ – StepRandom 1:16:49;2018-07-03 11:15:22.257059+02:00;2018-07-03 12:32:11.843190+02:00;66.2;21.8;Workbench 11.0a2;Short;Failure;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Motherboard 10: model 1001pxd, S/N eee0123456720;asustek computer inc.;1001pxd;eee0123456720;;;;;GraphicCard 5: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None;intel corporation;atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller;;256;;;;;;NetworkAdapter 2: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c9;qualcomm atheros;ar9285 wireless network adapter;74:2f:68:8b:fd:c9;NetworkAdapter 3: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7b;qualcomm atheros;ar8152 v2.0 fast ethernet;14:da:e9:42:f6:7b;SoundCard 6: model nm10/ich7 family high definition audio controller, S/N None;intel corporation;nm10/ich7 family high definition audio controller;;;;;;1.75;LOW;1.55;LOW;1.53;LOW;3.76;HIGH;52.50 €;15.7188 +64K64;;http://localhost/devices/64K64;;;;;;;;;;laptop-asustek_computer_inc-1001pxd-b8oaas048287-14:da:e9:42:f6:7c;Laptop;Netbook;b8oaas048287;1001pxd;asustek computer inc.;Thu Nov 12 19:53:02 2020;Workbench 11.0b11;2020-11-12 19:53:02.225373+01:00;;;;intel atom cpu n455 @ 1.66ghz;2048;558558;Processor 15: model intel atom cpu n455 @ 1.66ghz, S/N None;intel corp.;intel atom cpu n455 @ 1.66ghz;;1;1.667;6666.24;164.0803;;;;;;;;;RamModule 18: model None, S/N None;;;;1024;667;RamModule 19: model 48594d503131325336344350362d53362020, S/N 4f43487b;hynix semiconductor;48594d503131325336344350362d53362020;4f43487b;1024;667;;;;;;;;;;;;;HardDrive 20: model hts54322, S/N e2024242cv86hj;hitachi;hts54322;e2024242cv86hj;238475;harddrive-hitachi-hts54322-e2024242cv86hj;e2024242cv86hj;238475;Workbench 11.0b11;Success;EraseBasic;Shred;1:16:49;2020-11-12 19:53:02.175189+01:00;✓ – StepRandom 1:16:49;2018-07-03 11:15:22.257059+02:00;2018-07-03 12:32:11.843190+02:00;66.2;21.8;Workbench 11.0b11;Extended;Failure;;;DataStorage 21: model wdc wd1600bevt-2, S/N wd-wx11a80w7430;western digital;wdc wd1600bevt-2;wd-wx11a80w7430;160041;datastorage-western_digital-wdc_wd1600bevt-2-wd-wx11a80w7430;wd-wx11a80w7430;160041;Workbench 11.0b11;Failure;EraseBasic;Shred;0:45:36;2020-11-12 19:53:02.176882+01:00;✓ – StepRandom 0:45:36;2019-10-23 09:49:54.410830+02:00;2019-10-23 10:35:31.400587+02:00;41.6;17.3;Workbench 11.0b11;Short;Success;5293;195 days, 12:00:00;SolidStateDrive 22: model wdc wd1600bevt-2, S/N wd-wx11a80w7430;western digital;wdc wd1600bevt-2;wd-wx11a80w7430;160042;solidstatedrive-western_digital-wdc_wd1600bevt-2-wd-wx11a80w7430;wd-wx11a80w7430;160042;Workbench 11.0b11;Success;EraseSectors;Badblocks;1:46:03;2020-11-12 19:53:02.180043+01:00;✓ – StepRandom 0:46:03,✓ – StepZero 1:00:00;2019-08-19 18:48:19.690458+02:00,2019-08-19 19:34:22.690458+02:00;2019-08-19 19:34:22.930562+02:00,2019-08-19 20:34:22.930562+02:00;41.1;17.1;Workbench 11.0b11;Short;Success;5231;194 days, 17:00:00;;;;;;;;;;;;;;;;;;;;;;;;;Motherboard 23: model 1001pxd, S/N eee0123456789;asustek computer inc.;1001pxd;eee0123456789;;"auo ""auo""";auo lcd monitor;;GraphicCard 16: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None;intel corporation;atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller;;256;;;;;;NetworkAdapter 13: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c8;qualcomm atheros;ar9285 wireless network adapter;74:2f:68:8b:fd:c8;NetworkAdapter 14: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7c;qualcomm atheros;ar8152 v2.0 fast ethernet;14:da:e9:42:f6:7c;SoundCard 7: model usb 2.0 uvc vga webcam, S/N 0x0001;azurewave;usb 2.0 uvc vga webcam;0x0001;SoundCard 17: model nm10/ich7 family high definition audio controller, S/N None;intel corporation;nm10/ich7 family high definition audio controller;;1.72;LOW;1.31;LOW;1.99;LOW;3.97;HIGH;51.60 €;15.7188 diff --git a/tests/test_device_find.py b/tests/test_device_find.py index 7e9ac291..12d6c3d8 100644 --- a/tests/test_device_find.py +++ b/tests/test_device_find.py @@ -176,10 +176,10 @@ def test_device_query_filter_lots(user: UserClient): @pytest.mark.mvp def test_device_query(user: UserClient): """Checks result of inventory.""" - user.post(conftest.file('basic.snapshot'), res=Snapshot) + snap, _ = user.post(conftest.file('basic.snapshot'), res=Snapshot) i, _ = user.get(res=Device) assert i['url'] == '/devices/' - assert i['items'][0]['url'] == '/devices/1' + assert i['items'][0]['url'] == '/devices/%s' % snap['device']['devicehubID'] pc = next(d for d in i['items'] if d['type'] == 'Desktop') assert len(pc['actions']) == 4 assert len(pc['components']) == 3 diff --git a/tests/test_documents.py b/tests/test_documents.py index b1446156..e7eead7b 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -199,7 +199,7 @@ def test_live_example2(user: UserClient, client: Client, app: Devicehub): assert str(action_live[0].snapshot_uuid) == acer['uuid'] -@pytest.mark.mvp +@pytest.mark.mvp def test_export_basic_snapshot(user: UserClient): """Test export device information in a csv file.""" snapshot, _ = user.post(file('basic.snapshot'), res=Snapshot) diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index cd4d8b2c..a4f8ec79 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -63,7 +63,7 @@ def test_snapshot_model(): assert m.Desktop.query.one_or_none() is None assert m.Device.query.one_or_none() is None # Check properties - assert device.url == urlutils.URL('http://localhost/devices/1') + assert device.url == urlutils.URL('http://localhost/devices/%s' % device.devicehub_id) @pytest.mark.mvp @@ -115,7 +115,8 @@ def test_same_device_tow_users(user: UserClient, user2: UserClient): i, _ = user.get(res=m.Device) pc = next(d for d in i['items'] if d['type'] == 'Desktop') pc_id = pc['id'] - assert i['items'][0]['url'] == f'/devices/{pc_id}' + devicehub_id = pc['devicehubID'] + assert i['items'][0]['url'] == f'/devices/{devicehub_id}' basic_snapshot = file('basic.snapshot') basic_snapshot['uuid'] = f"{uuid.uuid4()}" @@ -550,7 +551,7 @@ def snapshot_and_check(user: UserClient, @pytest.mark.mvp @pytest.mark.usefixtures(conftest.app_context.__name__) def test_erase_changing_hdd_between_pcs(user: UserClient): - """Tests when we erase one device and next change the disk in other device we + """Tests when we erase one device and next change the disk in other device we want see in the second device the disks erase.""" s1 = file('erase-sectors-2-hdd.snapshot') s2 = file('erase-sectors-2-hdd.snapshot2') @@ -617,7 +618,7 @@ def test_save_snapshot_in_file(app: Devicehub, user: UserClient): @pytest.mark.mvp def test_action_no_snapshot_without_save_file(app: Devicehub, user: UserClient): - """ This test check if the function save_snapshot_in_file not work when we + """ This test check if the function save_snapshot_in_file not work when we send one other action different to snapshot """ s = file('laptop-hp_255_g3_notebook-hewlett-packard-cnd52270fw.snapshot') @@ -738,7 +739,7 @@ def test_snapshot_not_failed_null_chassis(app: Devicehub, user: UserClient): tmp_snapshots = app.config['TMP_SNAPSHOTS'] path_dir_base = os.path.join(tmp_snapshots, user.user['email'], 'errors') snapshot_error = file('desktop-9644w8n-lenovo-0169622.snapshot') - snapshot_error['device']['chassis'] = None + snapshot_error['device']['chassis'] = None uuid = snapshot_error['uuid'] snapshot, res = user.post(res=Snapshot, data=snapshot_error) @@ -819,7 +820,7 @@ def test_snapshot_bug_smallint_hdd(app: Devicehub, user: UserClient): snapshot, _ = user.post(res=Snapshot, data=snapshot_file) act = [act for act in snapshot['actions'] if act['type'] == 'TestDataStorage'][0] - assert act['currentPendingSectorCount'] == 473302660 + assert act['currentPendingSectorCount'] == 473302660 assert act['offlineUncorrectable'] == 182042944 tmp_snapshots = app.config['TMP_SNAPSHOTS'] @@ -837,5 +838,3 @@ def test_snapshot_mobil(app: Devicehub, user: UserClient): tmp_snapshots = app.config['TMP_SNAPSHOTS'] shutil.rmtree(tmp_snapshots) - - From 8f1eee0e89dadcd7ee5f12716c3e861e7634cd28 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 26 Mar 2021 17:57:45 +0100 Subject: [PATCH 13/16] fixing url to device --- ereuse_devicehub/resources/tag/view.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/resources/tag/view.py b/ereuse_devicehub/resources/tag/view.py index 24d8872a..081383ae 100644 --- a/ereuse_devicehub/resources/tag/view.py +++ b/ereuse_devicehub/resources/tag/view.py @@ -18,7 +18,7 @@ class TagView(View): tag = Tag.query.filter_by(internal_id=internal_id).one() # type: Tag if not tag.device: raise TagNotLinked(tag.id) - return redirect(location=url_for_resource(Device, tag.device.id)) + return redirect(location=url_for_resource(Device, tag.device.devicehub_id)) @auth.Auth.requires_auth def post(self): @@ -84,7 +84,7 @@ class TagDeviceView(View): raise TagNotLinked(tag.id) if not request.authorization: return redirect(location=url_for_resource(Device, tag.device.devicehub_id)) - return app.resources[Device.t].schema.jsonify(tag.device) + return app.resources[Device.t].schema.jsonify(tag.device.devicehub_id) @auth.Auth.requires_auth def one_authorization(self, id): From 83eeace6fa81fea511edd14e476f99aa9706fa0e Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 26 Mar 2021 17:58:05 +0100 Subject: [PATCH 14/16] fixing migrations --- .../migrations/versions/8cb91ad1cc40_add_code_to_device.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py index d387b26f..de2da555 100644 --- a/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py +++ b/ereuse_devicehub/migrations/versions/8cb91ad1cc40_add_code_to_device.py @@ -1,7 +1,7 @@ """add code to device Revision ID: 8cb91ad1cc40 -Revises: eca457d8b2a4 +Revises: 6a2a939d5668 Create Date: 2021-03-03 10:39:19.331027 """ @@ -15,7 +15,7 @@ from ereuse_devicehub.resources.utils import hashcode # revision identifiers, used by Alembic. revision = '8cb91ad1cc40' -down_revision = 'eca457d8b2a4' +down_revision = '6a2a939d5668' branch_labels = None depends_on = None From e1cca540c45b33ce6edbe743814c786158934e76 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 13 Apr 2021 19:02:16 +0200 Subject: [PATCH 15/16] change verification link for erasure certificate doc --- ereuse_devicehub/resources/documents/documents.py | 5 +---- .../resources/documents/templates/documents/erasure.html | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ereuse_devicehub/resources/documents/documents.py b/ereuse_devicehub/resources/documents/documents.py index cc47fd30..82008c69 100644 --- a/ereuse_devicehub/resources/documents/documents.py +++ b/ereuse_devicehub/resources/documents/documents.py @@ -102,13 +102,10 @@ class DocumentView(DeviceView): url_pdf = boltons.urlutils.URL(flask.request.url) url_pdf.query_params['format'] = 'PDF' - url_web = boltons.urlutils.URL(flask.request.url) - url_web.query_params['format'] = 'HTML' params = { 'title': 'Erasure Certificate', 'erasures': tuple(erasures()), - 'url_pdf': url_pdf.to_text(), - 'url_web': url_web.to_text() + 'url_pdf': url_pdf.to_text() } return flask.render_template('documents/erasure.html', **params) diff --git a/ereuse_devicehub/resources/documents/templates/documents/erasure.html b/ereuse_devicehub/resources/documents/templates/documents/erasure.html index 0a0767d5..5a16390c 100644 --- a/ereuse_devicehub/resources/documents/templates/documents/erasure.html +++ b/ereuse_devicehub/resources/documents/templates/documents/erasure.html @@ -87,6 +87,6 @@ Click here to download the PDF. {% endblock %} From 5dc319486a9c559c643aee119967eb292918b259 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Apr 2021 14:49:03 +0200 Subject: [PATCH 16/16] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f86a69d..fba01d57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ml). ## [1.0.5-beta] - [addend] #124 adding endpoint for extract the internal stats of use - [addend] #122 system for verify all documents that it's produced from devicehub +- [addend] #131 add one code for every device ## [1.0.4-beta] - [addend] #95 adding endpoint for check the hash of one report