diff --git a/ereuse_devicehub/resources/documents/device_row.py b/ereuse_devicehub/resources/documents/device_row.py index ecdc93d9..f46b931d 100644 --- a/ereuse_devicehub/resources/documents/device_row.py +++ b/ereuse_devicehub/resources/documents/device_row.py @@ -1,10 +1,12 @@ +""" This file frame a correct row for csv report """ + from collections import OrderedDict +from flask import url_for -from flask import current_app - -from ereuse_devicehub.resources.action.models import BenchmarkDataStorage, RateComputer, \ - TestDataStorage +from ereuse_devicehub.resources.enums import Severity from ereuse_devicehub.resources.device import models as d, states +from ereuse_devicehub.resources.action.models import (BenchmarkDataStorage, RateComputer, + TestDataStorage) class DeviceRow(OrderedDict): @@ -14,26 +16,55 @@ class DeviceRow(OrderedDict): d.GraphicCard.t: 2, d.Motherboard.t: 1, d.NetworkAdapter.t: 2, - d.SoundCard.t: 2 + d.SoundCard.t: 2, + d.RamModule.t: 4, + d.DataStorage: 5, } + ORDER_COMPONENTS = [ + d.Processor.t, + d.RamModule.t, + d.DataStorage.t, + d.Motherboard.t, + d.Display.t, + d.GraphicCard.t, + d.NetworkAdapter.t, + d.SoundCard.t, + ] - # TODO Add more fields information def __init__(self, device: d.Device) -> None: super().__init__() self.device = device + snapshot = get_action(device, 'Snapshot') + software = '' + if snapshot: + software = "{software} {version}".format( + software=snapshot.software.name, version=snapshot.version) # General information about device - self['Type'] = device.t - if isinstance(device, d.Computer): - self['Chassis'] = device.chassis - else: - self['Chassis'] = '' - self['Tag 1'] = self['Tag 2'] = self['Tag 3'] = '' + self['System ID'] = device.id + self['Public Link'] = '{url}{id}'.format(url=url_for('Device.main', _external=True), + id=device.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'] = '' for i, tag in zip(range(1, 3), device.tags): - self['Tag {}'.format(i)] = format(tag) - self['Serial Number'] = convert_none_to_empty_str(device.serial_number) - self['Model'] = convert_none_to_empty_str(device.model) - self['Manufacturer'] = convert_none_to_empty_str(device.manufacturer) + # TODO @cayop we need redefined how save the Tag Type info + self['Tag {} Type'.format(i)] = 'unamed' + self['Tag {} ID'.format(i)] = tag.id + self['Tag {} Organization'.format(i)] = tag.org.name + + self['Device Hardware ID'] = device.hid + self['Device Type'] = device.t + self['Device Chassis'] = '' + if isinstance(device, d.Computer): + self['Device Chassis'] = device.chassis.name + self['Device Serial Number'] = none2str(device.serial_number) + self['Device Model'] = none2str(device.model) + self['Device Manufacturer'] = none2str(device.manufacturer) self['Registered in'] = format(device.created, '%c') + self['Registered (process)'] = software + self['Updated in (software)'] = device.updated + self['Updated in (web)'] = '' + try: self['Physical state'] = device.last_action_of(*states.Physical.actions()).t except LookupError: @@ -42,105 +73,237 @@ class DeviceRow(OrderedDict): self['Trading state'] = device.last_action_of(*states.Trading.actions()).t except LookupError: self['Trading state'] = '' - self['Price'] = convert_none_to_empty_str(device.price) if isinstance(device, d.Computer): - self['Processor'] = convert_none_to_empty_str(device.processor_model) - self['RAM (MB)'] = convert_none_to_empty_str(device.ram_size) - self['Data Storage Size (MB)'] = convert_none_to_empty_str(device.data_storage_size) - rate = device.rate - if rate: - self['Rate'] = rate.rating - self['Range'] = rate.rating_range - assert isinstance(rate, RateComputer) - self['Processor Rate'] = rate.processor - self['Processor Range'] = rate.processor_range - self['RAM Rate'] = rate.ram - self['RAM Range'] = rate.ram_range - self['Data Storage Rate'] = rate.data_storage - self['Data Storage Range'] = rate.data_storage_range + self['Processor'] = none2str(device.processor_model) + self['RAM (MB)'] = none2str(device.ram_size) + self['Data Storage Size (MB)'] = none2str(device.data_storage_size) # More specific information about components if isinstance(device, d.Computer): self.components() + else: + # TODO @cayop we need add columns as a component + pass + + rate = device.rate + if rate: + self['Device Rate'] = rate.rating + self['Device Range'] = rate.rating_range.name + assert isinstance(rate, RateComputer) + self['Processor Rate'] = rate.processor + self['Processor Range'] = rate.processor_range.name + self['RAM Rate'] = rate.ram + self['RAM Range'] = rate.ram_range.name + self['Data Storage Rate'] = rate.data_storage + self['Data Storage Range'] = rate.data_storage_range.name + + self['Price'] = none2str(device.price) + + benchram = get_action(device, 'BenchmarkRamSysbench') + if benchram: + self['Benchmark RamSysbench (points)'] = none2str(benchram.rate) + else: + self['Benchmark RamSysbench (points)'] = '' def components(self): """Function to get all components information of a device.""" assert isinstance(self.device, d.Computer) - # todo put an input specific order (non alphabetic) & where are a list of types components - for type in sorted(current_app.resources[d.Component.t].subresources_types): # type: str - max = self.NUMS.get(type, 4) - if type not in ['Component', 'HardDrive', 'SolidStateDrive']: - i = 1 - for component in (r for r in self.device.components if r.type == type): - self.fill_component(type, i, component) - i += 1 - if i > max: - break - while i <= max: - self.fill_component(type, i) - i += 1 + for ctype in self.ORDER_COMPONENTS: # ctype: str + cmax = self.NUMS.get(ctype, 4) + i = 1 + l_ctype = [ctype] + if ctype == d.DataStorage.t: + l_ctype = [ctype, d.HardDrive.t, d.SolidStateDrive.t] + for component in (r for r in self.device.components if r.type in l_ctype): + self.fill_component(ctype, i, component) + i += 1 + if i > cmax: + break + while i <= cmax: + self.fill_component(ctype, i) + i += 1 - def fill_component(self, type, i, component=None): + def fill_component(self, ctype, i, component=None): """Function to put specific information of components in OrderedDict (csv) - :param type: type of component + :param ctype: type of component :param component: device.components """ - self['{} {}'.format(type, i)] = format(component) if component else '' - self['{} {} Manufacturer'.format(type, i)] = component.serial_number if component else '' - self['{} {} Model'.format(type, i)] = component.serial_number if component else '' - self['{} {} Serial Number'.format(type, i)] = component.serial_number if component else '' + # Basic fields for all components + self['{} {}'.format(ctype, i)] = format(component) if component else '' + if component is None: + self['{} {} Manufacturer'.format(ctype, i)] = '' + self['{} {} Model'.format(ctype, i)] = '' + self['{} {} Serial Number'.format(ctype, i)] = '' + else: + self['{} {} Manufacturer'.format(ctype, i)] = none2str(component.manufacturer) + self['{} {} Model'.format(ctype, i)] = none2str(component.model) + self['{} {} Serial Number'.format(ctype, i)] = none2str(component.serial_number) - """Particular fields for component GraphicCard.""" - if isinstance(component, d.GraphicCard): - self['{} {} Memory (MB)'.format(type, i)] = component.memory + if ctype == d.Processor.t: + self.get_processor(ctype, i, component) - """Particular fields for component DataStorage.t -> - (HardDrive, SolidStateDrive) - """ - if isinstance(component, d.DataStorage): - self['{} {} Size (MB)'.format(type, i)] = component.size - self['{} {} Privacy'.format(type, i)] = component.privacy - try: - self['{} {} Lifetime'.format(type, i)] = component.last_action_of( - TestDataStorage).lifetime - except: - self['{} {} Lifetime'.format(type, i)] = '' - try: - self['{} {} Reading speed'.format(type, i)] = component.last_action_of( - BenchmarkDataStorage).read_speed - except: - self['{} {} Reading speed'.format(type, i)] = '' - try: - self['{} {} Writing speed'.format(type, i)] = component.last_action_of( - BenchmarkDataStorage).write_speed - except: - self['{} {} Writing speed'.format(type, i)] = '' + if ctype == d.RamModule.t: + self.get_ram(ctype, i, component) + if ctype == d.DataStorage.t: + self.get_datastorage(ctype, i, component) + + if ctype == d.GraphicCard.t: + self.get_graphic_card(ctype, i, component) + + def get_processor(self, ctype, i, component): """Particular fields for component Processor.""" - if isinstance(component, d.Processor): - self['{} {} Number of cores'.format(type, i)] = component.cores - self['{} {} Speed (GHz)'.format(type, i)] = component.speed + if component is None: + self['{} {} Number of cores'.format(ctype, i)] = '' + self['{} {} Speed (GHz)'.format(ctype, i)] = '' + self['Benchmark {} {} (points)'.format(ctype, i)] = '' + self['Benchmark ProcessorSysbench {} {} (points)'.format(ctype, i)] = '' + return - """Particular fields for component RamModule.""" - if isinstance(component, d.RamModule): - self['{} {} Size (MB)'.format(type, i)] = component.size - self['{} {} Speed (MHz)'.format(type, i)] = component.speed + self['{} {} Number of cores'.format(ctype, i)] = none2str(component.cores) + self['{} {} Speed (GHz)'.format(ctype, i)] = none2str(component.speed) - # todo add Display, NetworkAdapter, etc... + benchmark = get_action(component, 'BenchmarkProcessor') + if not benchmark: + self['Benchmark {} {} (points)'.format(ctype, i)] = '' + else: + self['Benchmark {} {} (points)'.format(ctype, i)] = benchmark.rate + + sysbench = get_action(component, 'BenchmarkProcessorSysbench') + if not sysbench: + self['Benchmark ProcessorSysbench {} {} (points)'.format(ctype, i)] = '' + return + self['Benchmark ProcessorSysbench {} {} (points)'.format(ctype, i)] = sysbench.rate + + def get_ram(self, ctype, i, component): + """Particular fields for component Ram Module.""" + if component is None: + self['{} {} Size (MB)'.format(ctype, i)] = '' + self['{} {} Speed (MHz)'.format(ctype, i)] = '' + return + + self['{} {} Size (MB)'.format(ctype, i)] = none2str(component.size) + self['{} {} Speed (MHz)'.format(ctype, i)] = none2str(component.speed) + + def get_datastorage(self, ctype, i, component): + """Particular fields for component DataStorage. + A DataStorage can be HardDrive or SolidStateDrive. + """ + if component is None: + self['{} {} Size (MB)'.format(ctype, i)] = '' + self['Erasure {} {}'.format(ctype, i)] = '' + self['Erasure {} {} Serial Number'.format(ctype, i)] = '' + self['Erasure {} {} Size (MB)'.format(ctype, i)] = '' + self['Erasure {} {} Software'.format(ctype, i)] = '' + self['Erasure {} {} Result'.format(ctype, i)] = '' + self['Erasure {} {} Type'.format(ctype, i)] = '' + self['Erasure {} {} Method'.format(ctype, i)] = '' + self['Erasure {} {} Elapsed (hours)'.format(ctype, i)] = '' + self['Erasure {} {} Date'.format(ctype, i)] = '' + self['Erasure {} {} Steps'.format(ctype, i)] = '' + self['Erasure {} {} Steps Start Time'.format(ctype, i)] = '' + self['Erasure {} {} Steps End Time'.format(ctype, i)] = '' + self['Benchmark {} {} Read Speed (MB/s)'.format(ctype, i)] = '' + self['Benchmark {} {} Writing speed (MB/s)'.format(ctype, i)] = '' + self['Test {} {} Software'.format(ctype, i)] = '' + self['Test {} {} Type'.format(ctype, i)] = '' + self['Test {} {} Result'.format(ctype, i)] = '' + self['Test {} {} Power on (hours used)'.format(ctype, i)] = '' + self['Test {} {} Lifetime remaining (percentage)'.format(ctype, i)] = '' + return + + snapshot = get_action(component, 'Snapshot') + software = '' + if snapshot: + software = "{software} {version}".format( + software=snapshot.software.name, version=snapshot.version) + + self['{} {} Size (MB)'.format(ctype, i)] = none2str(component.size) + + erasures = [a for a in component.actions if a.type in ['EraseBasic', 'EraseSectors']] + erasure = erasures[-1] if erasures else None + if not erasure: + self['Erasure {} {}'.format(ctype, i)] = none2str(component.hid) + serial_number = none2str(component.serial_number) + self['Erasure {} {} Serial Number'.format(ctype, i)] = serial_number + self['Erasure {} {} Size (MB)'.format(ctype, i)] = none2str(component.size) + self['Erasure {} {} Software'.format(ctype, i)] = '' + self['Erasure {} {} Result'.format(ctype, i)] = '' + self['Erasure {} {} Type'.format(ctype, i)] = '' + self['Erasure {} {} Method'.format(ctype, i)] = '' + self['Erasure {} {} Elapsed (hours)'.format(ctype, i)] = '' + self['Erasure {} {} Date'.format(ctype, i)] = '' + self['Erasure {} {} Steps'.format(ctype, i)] = '' + self['Erasure {} {} Steps Start Time'.format(ctype, i)] = '' + self['Erasure {} {} Steps End Time'.format(ctype, i)] = '' + else: + self['Erasure {} {}'.format(ctype, i)] = none2str(component.hid) + serial_number = none2str(component.serial_number) + self['Erasure {} {} Serial Number'.format(ctype, i)] = serial_number + self['Erasure {} {} Size (MB)'.format(ctype, i)] = none2str(component.size) + self['Erasure {} {} Software'.format(ctype, i)] = software + + result = get_result(erasure.severity) + self['Erasure {} {} Result'.format(ctype, i)] = result + self['Erasure {} {} Type'.format(ctype, i)] = erasure.type + self['Erasure {} {} Method'.format(ctype, i)] = erasure.method + self['Erasure {} {} Elapsed (hours)'.format(ctype, i)] = format(erasure.elapsed) + self['Erasure {} {} Date'.format(ctype, i)] = format(erasure.created) + steps = ','.join((format(x) for x in erasure.steps)) + self['Erasure {} {} Steps'.format(ctype, i)] = steps + steps_start_time = ','.join((format(x.start_time) for x in erasure.steps)) + self['Erasure {} {} Steps Start Time'.format(ctype, i)] = steps_start_time + steps_end_time = ','.join((format(x.end_time) for x in erasure.steps)) + self['Erasure {} {} Steps End Time'.format(ctype, i)] = steps_end_time + + benchmark = get_action(component, 'BenchmarkDataStorage') + if not benchmark: + self['Benchmark {} {} Read Speed (MB/s)'.format(ctype, i)] = '' + self['Benchmark {} {} Writing speed (MB/s)'.format(ctype, i)] = '' + else: + self['Benchmark {} {} Read Speed (MB/s)'.format(ctype, i)] = none2str( + benchmark.read_speed) + self['Benchmark {} {} Writing speed (MB/s)'.format(ctype, i)] = none2str( + benchmark.write_speed) + + test_storage = get_action(component, 'TestDataStorage') + if not test_storage: + self['Test {} {} Software'.format(ctype, i)] = '' + self['Test {} {} Type'.format(ctype, i)] = '' + self['Test {} {} Result'.format(ctype, i)] = '' + self['Test {} {} Power on (hours used)'.format(ctype, i)] = '' + self['Test {} {} Lifetime remaining (percentage)'.format(ctype, i)] = '' + return + + self['Test {} {} Software'.format(ctype, i)] = software + self['Test {} {} Type'.format(ctype, i)] = test_storage.length.value + self['Test {} {} Result'.format(ctype, i)] = get_result(test_storage.severity) + self['Test {} {} Power on (hours used)'.format(ctype, i)] = none2str( + test_storage.power_cycle_count) + self['Test {} {} Lifetime remaining (percentage)'.format(ctype, i)] = none2str( + test_storage.lifetime) + + def get_graphic_card(self, ctype, i, component): + """Particular fields for component GraphicCard.""" + if component is None: + self['{} {} Memory (MB)'.format(ctype, i)] = '' + return + + self['{} {} Memory (MB)'.format(ctype, i)] = none2str(component.memory) class StockRow(OrderedDict): def __init__(self, device: d.Device) -> None: super().__init__() self.device = device - self['Type'] = convert_none_to_empty_str(device.t) + self['Type'] = none2str(device.t) if isinstance(device, d.Computer): self['Chassis'] = device.chassis else: self['Chassis'] = '' - self['Serial Number'] = convert_none_to_empty_str(device.serial_number) - self['Model'] = convert_none_to_empty_str(device.model) - self['Manufacturer'] = convert_none_to_empty_str(device.manufacturer) + self['Serial Number'] = none2str(device.serial_number) + self['Model'] = none2str(device.model) + self['Manufacturer'] = none2str(device.manufacturer) self['Registered in'] = format(device.created, '%c') try: self['Physical state'] = device.last_action_of(*states.Physical.actions()).t @@ -150,10 +313,10 @@ class StockRow(OrderedDict): self['Trading state'] = device.last_action_of(*states.Trading.actions()).t except LookupError: self['Trading state'] = '' - self['Price'] = convert_none_to_empty_str(device.price) - self['Processor'] = convert_none_to_empty_str(device.processor_model) - self['RAM (MB)'] = convert_none_to_empty_str(device.ram_size) - self['Data Storage Size (MB)'] = convert_none_to_empty_str(device.data_storage_size) + self['Price'] = none2str(device.price) + self['Processor'] = none2str(device.processor_model) + self['RAM (MB)'] = none2str(device.ram_size) + self['Data Storage Size (MB)'] = none2str(device.data_storage_size) rate = device.rate if rate: self['Rate'] = rate.rating @@ -167,7 +330,24 @@ class StockRow(OrderedDict): self['Data Storage Range'] = rate.data_storage_range -def convert_none_to_empty_str(s): - if s is None: +def get_result(severity): + """ For the csv is necessary simplify the message of results """ + type_of_results = { + Severity.Error: 'Failure', + Severity.Warning: 'Success with Warnings', + Severity.Notice: 'Success', + Severity.Info: 'Success' + } + return type_of_results[severity] + + +def none2str(string): + """ convert none to empty str """ + if string is None: return '' - return s + return format(string) + +def get_action(component, action): + """ Filter one action from a component or return None """ + result = [a for a in component.actions if a.type == action] + return result[-1] if result else None diff --git a/ereuse_devicehub/resources/documents/documents.py b/ereuse_devicehub/resources/documents/documents.py index 53bd8d82..e65bee81 100644 --- a/ereuse_devicehub/resources/documents/documents.py +++ b/ereuse_devicehub/resources/documents/documents.py @@ -117,7 +117,7 @@ class DevicesDocumentView(DeviceView): def generate_post_csv(self, query): """Get device query and put information in csv format.""" data = StringIO() - cw = csv.writer(data) + cw = csv.writer(data, delimiter=';', quotechar='"') first = True for device in query: d = DeviceRow(device) @@ -125,7 +125,7 @@ class DevicesDocumentView(DeviceView): cw.writerow(d.keys()) first = False cw.writerow(d.values()) - output = make_response(data.getvalue()) + output = make_response(data.getvalue().encode('utf-8')) output.headers['Content-Disposition'] = 'attachment; filename=export.csv' output.headers['Content-type'] = 'text/csv' return output diff --git a/tests/files/basic.csv b/tests/files/basic.csv index fc2d85d8..45f62b0b 100644 --- a/tests/files/basic.csv +++ b/tests/files/basic.csv @@ -1,2 +1,2 @@ -Type,Chassis,Tag 1,Tag 2,Tag 3,Serial Number,Model,Manufacturer,Registered in,Physical state,Trading state,Price,Processor,RAM (MB),Data Storage Size (MB),Rate,Range,Processor Rate,Processor Range,RAM Rate,RAM Range,Data Storage Rate,Data Storage Range,Battery 1,Battery 1 Manufacturer,Battery 1 Model,Battery 1 Serial Number,Battery 2,Battery 2 Manufacturer,Battery 2 Model,Battery 2 Serial Number,Battery 3,Battery 3 Manufacturer,Battery 3 Model,Battery 3 Serial Number,Battery 4,Battery 4 Manufacturer,Battery 4 Model,Battery 4 Serial Number,Camera 1,Camera 1 Manufacturer,Camera 1 Model,Camera 1 Serial Number,Camera 2,Camera 2 Manufacturer,Camera 2 Model,Camera 2 Serial Number,Camera 3,Camera 3 Manufacturer,Camera 3 Model,Camera 3 Serial Number,Camera 4,Camera 4 Manufacturer,Camera 4 Model,Camera 4 Serial Number,DataStorage 1,DataStorage 1 Manufacturer,DataStorage 1 Model,DataStorage 1 Serial Number,DataStorage 2,DataStorage 2 Manufacturer,DataStorage 2 Model,DataStorage 2 Serial Number,DataStorage 3,DataStorage 3 Manufacturer,DataStorage 3 Model,DataStorage 3 Serial Number,DataStorage 4,DataStorage 4 Manufacturer,DataStorage 4 Model,DataStorage 4 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,Motherboard 1,Motherboard 1 Manufacturer,Motherboard 1 Model,Motherboard 1 Serial Number,NetworkAdapter 1,NetworkAdapter 1 Manufacturer,NetworkAdapter 1 Model,NetworkAdapter 1 Serial Number,NetworkAdapter 2,NetworkAdapter 2 Manufacturer,NetworkAdapter 2 Model,NetworkAdapter 2 Serial Number,Processor 1,Processor 1 Manufacturer,Processor 1 Model,Processor 1 Serial Number,Processor 1 Number of cores,Processor 1 Speed (GHz),Processor 2,Processor 2 Manufacturer,Processor 2 Model,Processor 2 Serial Number,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 3,RamModule 3 Manufacturer,RamModule 3 Model,RamModule 3 Serial Number,RamModule 4,RamModule 4 Manufacturer,RamModule 4 Model,RamModule 4 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 -Desktop,Microtower,,,,d1s,d1ml,d1mr,Tue Jul 2 10:35:10 2019,,,,p1ml,0,0,1.0,Very low,1.0,Very low,1.0,Very low,1.0,Very low,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"GraphicCard 2: model gc1ml, S/N gc1s",gc1s,gc1s,gc1s,,,,,,,,,,,,,,,,,,"Processor 4: model p1ml, S/N p1s",p1s,p1s,p1s,,1.6,,,,,"RamModule 3: model rm1ml, S/N rm1s",rm1s,rm1s,rm1s,,1333,,,,,,,,,,,,,,,,,,,, +System ID;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;; \ No newline at end of file diff --git a/tests/files/complete.export.snapshot.yaml b/tests/files/complete.export.snapshot.yaml new file mode 100644 index 00000000..9cdd0863 --- /dev/null +++ b/tests/files/complete.export.snapshot.yaml @@ -0,0 +1,272 @@ +{ + "components": [ + { + "resolutionHeight": 600, + "model": "AUO LCD Monitor", + "manufacturer": "AUO \"AUO\"", + "size": 10.0, + "resolutionWidth": 1024, + "productionDate": "2009-01-04T00:00:00", + "refreshRate": 60, + "technology": "LCD", + "type": "Display", + "serialNumber": null, + "actions": [] + }, + { + "type": "NetworkAdapter", + "model": "AR9285 Wireless Network Adapter", + "serialNumber": "74:2f:68:8b:fd:c8", + "manufacturer": "Qualcomm Atheros", + "wireless": true, + "actions": [] + }, + { + "type": "NetworkAdapter", + "model": "AR8152 v2.0 Fast Ethernet", + "serialNumber": "14:da:e9:42:f6:7c", + "manufacturer": "Qualcomm Atheros", + "speed": 100, + "wireless": false, + "actions": [] + }, + { + "type": "Processor", + "cores": 1, + "threads": 1, + "address": 64, + "model": "Intel Atom CPU N455 @ 1.66GHz", + "serialNumber": null, + "manufacturer": "Intel Corp.", + "speed": 1.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": "DDR3", + "serialNumber": null, + "manufacturer": null, + "speed": 667.0, + "actions": [] + }, + { + "size": 1024.0, + "actions": [], + "format": "SODIMM", + "model": "48594D503131325336344350362D53362020", + "interface": "DDR3", + "type": "RamModule", + "manufacturer": "Hynix Semiconductor", + "serialNumber": "4F43487B", + "speed": 667.0 + }, + { + "type": "HardDrive", + "model": "HTS54322", + "size": 238475, + "interface": "ATA", + "serialNumber": "E2024242CV86HJ", + "manufacturer": "Hitachi", + "actions": [ + { + "type": "BenchmarkDataStorage", + "elapsed": 16, + "writeSpeed": 21.8, + "readSpeed": 66.2 + }, + { + "type": "TestDataStorage", + "length": "Extended", + "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" + } + ] + }, + { + "size": 160041.88569599998, + "variant": "1A01", + "actions": [ + { + "type": "EraseBasic", + "steps": [ + { + "type": "StepRandom", + "endTime": "2019-10-23T08:35:31.400587+00:00", + "severity": "Info", + "startTime": "2019-10-23T07:49:54.410830+00:00" + } + ], + "endTime": "2019-10-23T08:35:31.400988+00:00", + "severity": "Error", + "startTime": "2019-10-23T07:49:54.410193+00:00" + }, + { + "elapsed": 22, + "writeSpeed": 17.3, + "readSpeed": 41.6, + "type": "BenchmarkDataStorage" + }, + { + "status": "Completed without error", + "reallocatedSectorCount": 0, + "currentPendingSectorCount": 0, + "assessment": true, + "severity": "Info", + "offlineUncorrectable": 0, + "lifetime": 4692, + "type": "TestDataStorage", + "length": "Short", + "elapsed": 118, + "powerCycleCount": 5293 + } + ], + "model": "WDC WD1600BEVT-2", + "interface": "ATA", + "type": "DataStorage", + "manufacturer": "Western Digital", + "serialNumber": "WD-WX11A80W7430" + }, + { + "actions": [ + { + "writeSpeed": 17.1, + "type": "BenchmarkDataStorage", + "elapsed": 22, + "readSpeed": 41.1 + }, + { + "type": "EraseSectors", + "startTime": "2019-08-19T16:48:19.689794+00:00", + "steps": [ + { + "startTime": "2019-08-19T16:48:19.690458+00:00", + "type": "StepRandom", + "severity": "Info", + "endTime": "2019-08-19T17:34:22.930562+00:00" + }, + { + "startTime": "2019-08-19T17:34:22.690458+00:00", + "type": "StepZero", + "severity": "Info", + "endTime": "2019-08-19T18:34:22.930562+00:00" + } + ], + "severity": "Info", + "endTime": "2019-08-19T18:34:22.930959+00:00" + }, + { + "currentPendingSectorCount": 0, + "lifetime": 4673, + "elapsed": 115, + "reallocatedSectorCount": 0, + "powerCycleCount": 5231, + "status": "Completed without error", + "assessment": true, + "type": "TestDataStorage", + "severity": "Info", + "length": "Short", + "offlineUncorrectable": 0 + } + ], + "model": "WDC WD1600BEVT-2", + "manufacturer": "Western Digital", + "size": 160042.0, + "interface": "ATA", + "serialNumber": "WD-WX11A80W7430", + "type": "SolidStateDrive", + "variant": "1A01" + }, + { + "type": "Motherboard", + "serial": 1, + "firewire": 0, + "model": "1001PXD", + "slots": 2, + "pcmcia": 0, + "serialNumber": "Eee0123456789", + "usb": 5, + "manufacturer": "ASUSTeK Computer INC.", + "actions": [ + { + "type": "TestBios", + "accessRange": "C" + } + ] + } + ], + "elapsed": 4875, + "uuid": "3fd12a01-c04e-4fd8-9e64-2660c459e725", + "version": "11.0b11", + "type": "Snapshot", + "software": "Workbench", + "device": { + "type": "Laptop", + "model": "1001PXD", + "serialNumber": "B8OAAS048287", + "manufacturer": "ASUSTeK Computer INC.", + "chassis": "Netbook", + "actions": [ + { + "type": "BenchmarkRamSysbench", + "rate": 15.7188, + "elapsed": 16 + }, + { + "type": "StressTest", + "severity": "Info", + "elapsed": 60 + } + ] + } +} diff --git a/tests/files/proposal_extended_csv_report.csv b/tests/files/proposal_extended_csv_report.csv new file mode 100644 index 00000000..5bca6df3 --- /dev/null +++ b/tests/files/proposal_extended_csv_report.csv @@ -0,0 +1,3 @@ +System ID;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;Laptop;Netbook;b8oaas048285;1001pxd;asustek computer inc.;Thu Oct 22 13:22:41 2020;Workbench 11.0a2;2020-10-22 13:22:41.206873+02: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-10-22 13:22:41.274142+02: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;Laptop;Netbook;b8oaas048287;1001pxd;asustek computer inc.;Thu Oct 22 13:22:41 2020;Workbench 11.0b11;2020-10-22 13:22:41.449469+02: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-10-22 13:22:41.462162+02: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-10-22 13:22:41.463826+02: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-10-22 13:22:41.466798+02: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/files/real-eee-1001pxd.snapshot.12.yaml b/tests/files/real-eee-1001pxd.snapshot.12.yaml new file mode 100644 index 00000000..6dc974bd --- /dev/null +++ b/tests/files/real-eee-1001pxd.snapshot.12.yaml @@ -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 +} diff --git a/tests/test_documents.py b/tests/test_documents.py index 15741775..0736856d 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -8,9 +8,13 @@ import teal.marshmallow from ereuse_utils.test import ANY from ereuse_devicehub.client import Client, UserClient +from ereuse_devicehub.devicehub import Devicehub from ereuse_devicehub.resources.action.models import Snapshot from ereuse_devicehub.resources.documents import documents +from ereuse_devicehub.resources.device import models as d from ereuse_devicehub.resources.lot.models import Lot +from ereuse_devicehub.resources.tag.model import Tag +from ereuse_devicehub.db import db from tests.conftest import file @@ -84,52 +88,68 @@ def test_export_basic_snapshot(user: UserClient): accept='text/csv', query=[('filter', {'type': ['Computer']})]) f = StringIO(csv_str) - obj_csv = csv.reader(f, f) + obj_csv = csv.reader(f, f, delimiter=';', quotechar='"') export_csv = list(obj_csv) # Open fixture csv and transform to list with Path(__file__).parent.joinpath('files').joinpath('basic.csv').open() as csv_file: - obj_csv = csv.reader(csv_file) + obj_csv = csv.reader(csv_file, delimiter=';', quotechar='"') fixture_csv = list(obj_csv) - assert isinstance(datetime.strptime(export_csv[1][8], '%c'), datetime), \ + assert isinstance(datetime.strptime(export_csv[1][17], '%c'), datetime), \ 'Register in field is not a datetime' - # Pop dates fields from csv lists to compare them - fixture_csv[1] = fixture_csv[1][:8] + fixture_csv[1][9:] - export_csv[1] = export_csv[1][:8] + export_csv[1][9:] - assert fixture_csv[0] == export_csv[0], 'Headers are not equal' - assert fixture_csv[1] == export_csv[1], 'Computer information are not equal' - + assert fixture_csv[1][:17] == export_csv[1][:17], 'Computer information are not equal' + assert fixture_csv[1][18] == export_csv[1][18], 'Computer information are not equal' + assert fixture_csv[1][20:] == export_csv[1][20:], 'Computer information are not equal' @pytest.mark.mvp -def test_export_full_snapshot(user: UserClient): +def test_export_extended(app: Devicehub, user: UserClient): """Test a export device with all information and a lot of components.""" - snapshot, _ = user.post(file('real-eee-1001pxd.snapshot.11'), res=Snapshot) + snapshot1, _ = user.post(file('real-eee-1001pxd.snapshot.12'), res=Snapshot, status=201) + snapshot2, _ = user.post(file('complete.export.snapshot'), res=Snapshot, status=201) + with app.app_context(): + # Create a pc with a tag + tag = Tag(id='foo', owner_id=user.user['id']) + # pc = Desktop(serial_number='sn1', chassis=ComputerChassis.Tower, owner_id=user.user['id']) + pc = d.Device.query.filter_by(id=snapshot1['device']['id']).first() + pc.tags.add(tag) + db.session.add(pc) + db.session.commit() csv_str, _ = user.get(res=documents.DocumentDef.t, item='devices/', accept='text/csv', query=[('filter', {'type': ['Computer']})]) + f = StringIO(csv_str) - obj_csv = csv.reader(f, f) + obj_csv = csv.reader(f, f, delimiter=';', quotechar='"') export_csv = list(obj_csv) # Open fixture csv and transform to list - with Path(__file__).parent.joinpath('files').joinpath('real-eee-1001pxd.csv').open() \ - as csv_file: - obj_csv = csv.reader(csv_file) + with Path(__file__).parent.joinpath('files').joinpath( + 'proposal_extended_csv_report.csv').open() as csv_file: + obj_csv = csv.reader(csv_file, delimiter=';', quotechar='"') fixture_csv = list(obj_csv) - assert isinstance(datetime.strptime(export_csv[1][8], '%c'), datetime), \ + assert isinstance(datetime.strptime(export_csv[1][17], '%c'), datetime), \ 'Register in field is not a datetime' - # Pop dates fields from csv lists to compare them - fixture_csv[1] = fixture_csv[1][:8] + fixture_csv[1][9:] - export_csv[1] = export_csv[1][:8] + export_csv[1][9:] - assert fixture_csv[0] == export_csv[0], 'Headers are not equal' - assert fixture_csv[1] == export_csv[1], 'Computer information are not equal' + assert fixture_csv[1][:17] == export_csv[1][:17], 'Computer information are not equal' + assert fixture_csv[1][18] == export_csv[1][18], 'Computer information are not equal' + assert fixture_csv[1][20:79] == export_csv[1][20:79], 'Computer information are not equal' + assert fixture_csv[1][80] == export_csv[1][80], 'Computer information are not equal' + assert fixture_csv[1][83:] == export_csv[1][83:], 'Computer information are not equal' + assert fixture_csv[2][:17] == export_csv[2][:17], 'Computer information are not equal' + assert fixture_csv[2][18] == export_csv[2][18], 'Computer information are not equal' + assert fixture_csv[2][20:79] == export_csv[2][20:79], 'Computer information are not equal' + assert fixture_csv[2][80] == export_csv[2][80], 'Computer information are not equal' + assert fixture_csv[2][83:103] == export_csv[2][83:103], 'Computer information are not equal' + assert fixture_csv[2][104] == export_csv[2][104], 'Computer information are not equal' + assert fixture_csv[2][107:127] == export_csv[2][107:127], 'Computer information are not equal' + assert fixture_csv[2][128] == export_csv[2][128], 'Computer information are not equal' + assert fixture_csv[2][131:] == export_csv[2][131:], 'Computer information are not equal' @pytest.mark.mvp