Merge pull request #112 from eReuse/bugfix/bug-#1862

Bugfix/bug #1862
This commit is contained in:
cayop 2021-01-26 17:29:10 +01:00 committed by GitHub
commit e17652abf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 184 additions and 16 deletions

View File

@ -5,8 +5,6 @@
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
<tr> <tr>
<th>S/N</th>
<th>Tags</th>
<th>S/N Data Storage</th> <th>S/N Data Storage</th>
<th>Type of erasure</th> <th>Type of erasure</th>
<th>Result</th> <th>Result</th>
@ -16,16 +14,6 @@
<tbody> <tbody>
{% for erasure in erasures %} {% for erasure in erasures %}
<tr> <tr>
{% if erasure.parent.serial_number %}
<td>
{{ erasure.parent.serial_number.upper() }}
</td>
{% else %}
<td></td>
{% endif %}
<td>
{{ erasure.parent.tags.__format__('') }}
</td>
<td> <td>
{{ erasure.device.serial_number.upper() }} {{ erasure.device.serial_number.upper() }}
</td> </td>
@ -51,10 +39,19 @@
<dl> <dl>
<dt>Data storage:</dt> <dt>Data storage:</dt>
<dd>{{ erasure.device.__format__('ts') }}</dd> <dd>{{ erasure.device.__format__('ts') }}</dd>
<dt>Computer:</dt>
<dd>{{ erasure.parent.__format__('ts') }}</dd> <dt>Computer where was erase:</dt>
<dt>Tags:</dt> <dd>Title: {{ erasure.parent.__format__('ts') }}</dd>
<dd>{{ erasure.parent.tags }}</dd> <dd>SystemId: {{ erasure.parent.id }}</dd>
<dd>Hid: {{ erasure.parent.hid }}</dd>
<dd>Tags: {{ erasure.parent.tags }}</dd>
<dt>Computer where it resides:</dt>
<dd>Title: {{ erasure.device.parent.__format__('ts') }}</dd>
<dd>SystemId: {{ erasure.device.parent.id }}</dd>
<dd>Hid: {{ erasure.device.parent.hid }}</dd>
<dd>Tags: {{ erasure.device.parent.tags }}</dd>
<dt>Erasure:</dt> <dt>Erasure:</dt>
<dd>{{ erasure.__format__('ts') }}</dd> <dd>{{ erasure.__format__('ts') }}</dd>
{% if erasure.steps %} {% if erasure.steps %}

View File

@ -0,0 +1,141 @@
{
"version": "11.0a3",
"device": {
"serialNumber": 'fooz',
"manufacturer": 'bar',
"model": 'baz',
"type": "Desktop",
"actions": [],
"chassis": "Tower"
},
"elapsed": 7631,
"software": "Workbench",
"type": "Snapshot",
"closed": false,
"uuid": "5387668a-8d21-4053-a1ac-36efb97fc4ea",
"components": [
{
"serialNumber": null,
"threads": 2,
"manufacturer": "Intel Corp.",
"address": 64,
"model": "Intel Core i3-2100 CPU @ 3.10GHz",
"type": "Processor",
"actions": [
{
"elapsed": 0,
"rate": 6665.7,
"type": "BenchmarkProcessor"
}
],
"cores": 2,
"speed": 1.6071410000000002
},
{
"manufacturer": "Intel Corporation",
"model": "6 Series/C200 Series Chipset Family High Definition Audio Controller",
"type": "SoundCard",
"actions": [],
"serialNumber": null
},
{
"serialNumber": "8F179435",
"size": 4096,
"manufacturer": "Kingston",
"format": "DIMM",
"model": "9905403-038.A00LF",
"type": "RamModule",
"actions": [],
"interface": "DDR3",
"speed": 1333.0
},
{
"manufacturer": "Realtek Semiconductor Co., Ltd.",
"model": "RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller",
"type": "NetworkAdapter",
"actions": [],
"serialNumber": "f4:6d:04:12:9b:85",
"speed": 1000,
"wireless": false
},
{
"serialNumber": "WD-WCAV29008961",
"size": 305245,
"manufacturer": "Western Digital",
"model": "WDC WD3200AAJS-2",
"type": "HardDrive",
"actions": [
{
"lifetime": 24658,
"assessment": false,
"elapsed": 131,
"length": "Short",
"offlineUncorrectable": 1,
"severity": "Error",
"currentPendingSectorCount": 1,
"powerCycleCount": 1253,
"reallocatedSectorCount": 15,
"type": "TestDataStorage",
"status": "Completed: read failure"
},
{
"readSpeed": 63.3,
"type": "BenchmarkDataStorage",
"elapsed": 18,
"writeSpeed": 20.1
}
],
"interface": "ATA"
},
{
"serialNumber": "WD-WCAV27984668",
"size": 305245,
"manufacturer": "Western Digital",
"model": "WDC WD3200AAJS-0",
"type": "HardDrive",
"actions": [
{
"lifetime": 21979,
"assessment": true,
"elapsed": 115,
"length": "Short",
"offlineUncorrectable": 0,
"severity": "Info",
"currentPendingSectorCount": 0,
"powerCycleCount": 1956,
"reallocatedSectorCount": 0,
"type": "TestDataStorage",
"status": "Completed without error"
},
{
"readSpeed": 63.3,
"type": "BenchmarkDataStorage",
"elapsed": 18,
"writeSpeed": 20.1
}
],
"interface": "ATA"
},
{
"serialNumber": null,
"manufacturer": "Intel Corporation",
"model": "2nd Generation Core Processor Family Integrated Graphics Controller",
"type": "GraphicCard",
"actions": [],
"memory": 256.0
},
{
"pcmcia": 0,
"serial": 1,
"manufacturer": "ASUSTeK Computer INC.",
"model": "P8H61-M LE",
"type": "Motherboard",
"actions": [],
"slots": 2,
"usb": 2,
"firewire": 0,
"serialNumber": "109192430003458"
}
],
"endTime": "2018-07-13T10:48:36.738398+00:00"
}

View File

@ -13,6 +13,7 @@ from uuid import uuid4
from boltons import urlutils from boltons import urlutils
from teal.db import UniqueViolation, DBError from teal.db import UniqueViolation, DBError
from teal.marshmallow import ValidationError from teal.marshmallow import ValidationError
from ereuse_utils.test import ANY
from ereuse_devicehub.client import UserClient from ereuse_devicehub.client import UserClient
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
@ -29,7 +30,9 @@ from ereuse_devicehub.resources.enums import ComputerChassis, SnapshotSoftware
from ereuse_devicehub.resources.tag import Tag from ereuse_devicehub.resources.tag import Tag
from ereuse_devicehub.resources.user.models import User from ereuse_devicehub.resources.user.models import User
from ereuse_devicehub.resources.action.views import save_json from ereuse_devicehub.resources.action.views import save_json
from ereuse_devicehub.resources.documents import documents
from tests.conftest import file from tests.conftest import file
from tests import conftest
@pytest.mark.mvp @pytest.mark.mvp
@ -542,6 +545,32 @@ def snapshot_and_check(user: UserClient,
return snapshot return snapshot
@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
want see in the second device the disks erase."""
s1 = file('erase-sectors-2-hdd.snapshot')
s2 = file('erase-sectors-2-hdd.snapshot2')
snapshot1, _ = user.post(res=Snapshot, data=s1)
snapshot2, _ = user.post(res=Snapshot, data=s2)
dev1 = m.Device.query.filter_by(id=snapshot1['device']['id']).one()
dev2 = m.Device.query.filter_by(id=snapshot2['device']['id']).one()
tag1 = Tag(id='dev1', device=dev1)
tag2 = Tag(id='dev2', device=dev2)
db.session.commit()
assert dev2.components[1].actions[2].parent == dev1
doc1, response = user.get(res=documents.DocumentDef.t,
item='erasures/{}'.format(dev1.id),
accept=ANY)
doc2, response = user.get(res=documents.DocumentDef.t,
item='erasures/{}'.format(dev2.id),
accept=ANY)
assert 'dev1' in doc2
assert 'dev2' in doc2
@pytest.mark.mvp @pytest.mark.mvp
@pytest.mark.xfail(reason='Debug and rewrite it') @pytest.mark.xfail(reason='Debug and rewrite it')
def test_pc_rating_rate_none(user: UserClient): def test_pc_rating_rate_none(user: UserClient):
@ -557,6 +586,7 @@ def test_pc_2(user: UserClient):
snapshot, _ = user.post(res=Snapshot, data=s) snapshot, _ = user.post(res=Snapshot, data=s)
@pytest.mark.mvp @pytest.mark.mvp
def test_save_snapshot_in_file(app: Devicehub, user: UserClient): def test_save_snapshot_in_file(app: Devicehub, user: UserClient):
""" This test check if works the function save_snapshot_in_file """ """ This test check if works the function save_snapshot_in_file """