Merge pull request #358 from eReuse/changes/3791-changes-export-device

Changes/3791 changes export device
This commit is contained in:
cayop 2022-09-21 16:10:59 +02:00 committed by GitHub
commit 553f85776a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 207 additions and 47 deletions

View File

@ -34,10 +34,20 @@ class BaseDeviceRow(OrderedDict):
def __init__(self) -> None:
super().__init__()
self['PHID'] = ''
self['DHID'] = ''
self['Type'] = ''
self['Placeholder Palet'] = ''
self['Placeholder Id Supplier'] = ''
self['Placeholder Info'] = ''
self['Placeholder Components'] = ''
self['Placeholder Type'] = ''
self['Placeholder Serial Number'] = ''
self['Placeholder Part Number'] = ''
self['Placeholder Model'] = ''
self['Placeholder Manufacturer'] = ''
self['DocumentID'] = ''
self['Public Link'] = ''
self['Lots'] = ''
self['Tag 1 Type'] = ''
self['Tag 1 ID'] = ''
self['Tag 1 Organization'] = ''
@ -250,18 +260,6 @@ class BaseDeviceRow(OrderedDict):
self['Data Storage Rate'] = ''
self['Data Storage Range'] = ''
self['Benchmark RamSysbench (points)'] = ''
# Placeholder
self['PHID'] = ''
self['Is Snapshot'] = ''
self['Pallet'] = ''
self['id Supplier'] = ''
self['Placeholder Info'] = ''
self['Placeholder Components'] = ''
self['Placeholder Type'] = ''
self['Placeholder Serial Number'] = ''
self['Placeholder Part Number'] = ''
self['Placeholder Model'] = ''
self['Placeholder Manufacturer'] = ''
class DeviceRow(BaseDeviceRow):
@ -282,7 +280,6 @@ class DeviceRow(BaseDeviceRow):
self['Public Link'] = '{url}{id}'.format(
url=url_for('Device.main', _external=True), id=device.dhid
)
self['Lots'] = ', '.join([x.name for x in self.device.lots])
for i, tag in zip(range(1, 3), device.tags):
self['Tag {} Type'.format(i)] = 'unamed' if tag.provider else 'named'
self['Tag {} ID'.format(i)] = tag.id
@ -506,9 +503,9 @@ class DeviceRow(BaseDeviceRow):
def get_placeholder_datas(self):
# Placeholder
self['PHID'] = none2str(self.placeholder.phid)
self['Is Snapshot'] = none2str(self.device.is_abstract())
self['Pallet'] = none2str(self.placeholder.pallet)
self['id Supplier'] = none2str(self.placeholder.id_device_supplier)
self['Type'] = none2str(self.device.is_abstract())
self['Placeholder Palet'] = none2str(self.placeholder.pallet)
self['Placeholder Id Supplier'] = none2str(self.placeholder.id_device_supplier)
self['Placeholder Info'] = none2str(self.placeholder.info)
self['Placeholder Components'] = none2str(self.placeholder.components)
self['Placeholder Type'] = none2str(self.placeholder.device.type)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,162 @@
{
"components": [
{
"type": "NetworkAdapter",
"model": "AR9285 Wireless Network Adapter",
"serialNumber": "74:2f:68:8b:fd:c9",
"manufacturer": "Qualcomm Atheros",
"wireless": true,
"actions": []
},
{
"type": "NetworkAdapter",
"model": "AR8152 v2.0 Fast Ethernet",
"serialNumber": "14:da:e9:42:f6:7b",
"manufacturer": "Qualcomm Atheros",
"speed": 100,
"wireless": false,
"actions": []
},
{
"type": "Processor",
"cores": 1,
"threads": 1,
"address": 64,
"model": "Intel Atom CPU N455 @ 2.66GHz",
"serialNumber": null,
"manufacturer": "Intel Corp.",
"speed": 2.667,
"actions": [
{
"type": "BenchmarkProcessorSysbench",
"rate": 164.0803,
"elapsed": 164
},
{
"type": "BenchmarkProcessor",
"rate": 6666.24,
"elapsed": 0
}
]
},
{
"type": "GraphicCard",
"model": "Atom Processor D4xx/D5xx/N4xx/N5xx Integrated Graphics Controller",
"serialNumber": null,
"memory": 256.0,
"manufacturer": "Intel Corporation",
"actions": []
},
{
"type": "SoundCard",
"model": "NM10/ICH7 Family High Definition Audio Controller",
"serialNumber": null,
"manufacturer": "Intel Corporation",
"actions": []
},
{
"type": "SoundCard",
"model": "USB 2.0 UVC VGA WebCam",
"serialNumber": "0x0001",
"manufacturer": "Azurewave",
"actions": []
},
{
"type": "RamModule",
"format": "DIMM",
"model": null,
"size": 1024,
"interface": "DDR2",
"serialNumber": null,
"manufacturer": null,
"speed": 667.0,
"actions": []
},
{
"type": "HardDrive",
"model": "HTS54322",
"size": 238475,
"interface": "ATA",
"serialNumber": "E2024242CV86MM",
"manufacturer": "Hitachi",
"actions": [
{
"type": "BenchmarkDataStorage",
"elapsed": 16,
"writeSpeed": 21.8,
"readSpeed": 66.2
},
{
"type": "TestDataStorage",
"length": "Short",
"elapsed": 2,
"severity": "Error",
"status": "Unspecified Error. Self-test not started."
},
{
"type": "EraseBasic",
"steps": [
{
"type": "StepRandom",
"startTime": "2018-07-03T09:15:22.257059+00:00",
"severity": "Info",
"endTime": "2018-07-03T10:32:11.843190+00:00"
}
],
"startTime": "2018-07-03T09:15:22.256074+00:00",
"severity": "Info",
"endTime": "2018-07-03T10:32:11.848455+00:00"
}
]
},
{
"type": "Motherboard",
"serial": 1,
"firewire": 0,
"model": "1001PXD",
"slots": 2,
"pcmcia": 0,
"serialNumber": "Eee0123456720",
"usb": 5,
"manufacturer": "ASUSTeK Computer INC.",
"actions": [
{
"type": "TestBios",
"accessRange": "C"
}
]
}
],
"elapsed": 4875,
"uuid": "c058e8d2-fb92-47cb-a4b7-522b75561135",
"version": "11.0a2",
"type": "Snapshot",
"software": "Workbench",
"endTime": "2018-07-03T09:10:57.034598+00:00",
"device": {
"type": "Laptop",
"model": "1001PXD",
"serialNumber": "B8OAAS048285",
"manufacturer": "ASUSTeK Computer INC.",
"chassis": "Netbook",
"actions": [
{
"type": "BenchmarkRamSysbench",
"rate": 15.7188,
"elapsed": 16
},
{
"type": "StressTest",
"severity": "Info",
"elapsed": 60
},
{
"appearanceRange": "B",
"functionalityRange": "A",
"type": "VisualTest"
}
]
},
"closed": false
}

View File

@ -269,11 +269,11 @@ def test_export_basic_snapshot(user: UserClient):
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert (
fixture_csv[1][:19] == export_csv[1][:19]
fixture_csv[1][:29] == export_csv[1][:29]
), 'Computer information are not equal'
assert fixture_csv[1][20] == export_csv[1][20], 'Computer information are not equal'
assert fixture_csv[1][30] == export_csv[1][30], 'Computer information are not equal'
assert (
fixture_csv[1][22:] == export_csv[1][22:]
fixture_csv[1][32:] == export_csv[1][32:]
), 'Computer information are not equal'
@ -339,38 +339,38 @@ def test_export_extended(app: Devicehub, user: UserClient):
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert (
fixture_csv[1][:19] == export_csv[1][:19]
fixture_csv[1][:29] == export_csv[1][:29]
), 'Computer information are not equal'
assert fixture_csv[1][20] == export_csv[1][20], 'Computer information are not equal'
assert fixture_csv[1][30] == export_csv[1][30], 'Computer information are not equal'
assert (
fixture_csv[1][22:83] == export_csv[1][22:83]
fixture_csv[1][32:93] == export_csv[1][32:93]
), 'Computer information are not equal'
assert fixture_csv[1][84] == export_csv[1][84], 'Computer information are not equal'
assert fixture_csv[1][94] == export_csv[1][94], 'Computer information are not equal'
assert (
fixture_csv[1][87:] == export_csv[1][87:]
fixture_csv[1][97:] == export_csv[1][97:]
), 'Computer information are not equal'
assert (
fixture_csv[2][:19] == export_csv[2][:19]
fixture_csv[2][:29] == export_csv[2][:29]
), 'Computer information are not equal'
assert fixture_csv[2][20] == export_csv[2][20], 'Computer information are not equal'
assert fixture_csv[2][30] == export_csv[2][30], 'Computer information are not equal'
assert (
fixture_csv[2][22:83] == export_csv[2][22:83]
fixture_csv[2][32:93] == export_csv[2][32:93]
), 'Computer information are not equal'
assert fixture_csv[2][84] == export_csv[2][84], 'Computer information are not equal'
assert fixture_csv[2][94] == export_csv[2][94], 'Computer information are not equal'
assert (
fixture_csv[2][87:107] == export_csv[2][87:107]
fixture_csv[2][97:107] == export_csv[2][97:107]
), 'Computer information are not equal'
assert (
fixture_csv[2][110] == export_csv[2][110]
fixture_csv[2][120] == export_csv[2][120]
), 'Computer information are not equal'
assert (
fixture_csv[2][113:134] == export_csv[2][113:134]
fixture_csv[2][123:144] == export_csv[2][123:144]
), 'Computer information are not equal'
assert (
fixture_csv[2][136] == export_csv[2][136]
fixture_csv[2][146] == export_csv[2][146]
), 'Computer information are not equal'
assert (
fixture_csv[2][139:] == export_csv[2][139:]
fixture_csv[2][149:] == export_csv[2][149:]
), 'Computer information are not equal'

View File

@ -223,16 +223,17 @@ def test_export_devices(user3: UserClientFlask):
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert (
fixture_csv[1][:19] == export_csv[1][:19]
fixture_csv[1][:29] == export_csv[1][:29]
), 'Computer information are not equal'
assert fixture_csv[1][20] == export_csv[1][20], 'Computer information are not equal'
assert fixture_csv[1][30] == export_csv[1][30], 'Computer information are not equal'
# import pdb; pdb.set_trace()
assert (
fixture_csv[1][22:83] == export_csv[1][22:83]
fixture_csv[1][32:93] == export_csv[1][32:93]
), 'Computer information are not equal'
assert fixture_csv[1][84] == export_csv[1][84], 'Computer information are not equal'
assert fixture_csv[1][94] == export_csv[1][94], 'Computer information are not equal'
assert (
fixture_csv[1][88:] == export_csv[1][88:]
fixture_csv[1][98:] == export_csv[1][98:]
), 'Computer information are not equal'
@ -1660,7 +1661,7 @@ def test_export_lots(user3: UserClientFlask):
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_export_snapshot_json(user3: UserClientFlask):
file_name = 'real-eee-1001pxd.snapshot.12.json'
file_name = 'real-eee-1001pxd.snapshot.13.json'
snap = create_device(user3, file_name)
snapshot = conftest.yaml2json(file_name.split(".json")[0])