From c5da07ef9c3257d5b17bdfd97fe225c61a9796db Mon Sep 17 00:00:00 2001 From: nad Date: Wed, 6 Mar 2019 18:44:21 +0100 Subject: [PATCH] Add new tests and update some fixtures --- tests/files/basic.csv | 4 +- tests/files/computer-monitor.csv | 4 +- tests/files/keyboard.csv | 4 +- tests/files/multiples_devices.csv | 17 ++++++++ tests/files/real-eee-1001pxd.csv | 4 +- tests/test_reports.py | 71 ++++++++++++++++++------------- 6 files changed, 67 insertions(+), 37 deletions(-) create mode 100644 tests/files/multiples_devices.csv diff --git a/tests/files/basic.csv b/tests/files/basic.csv index db045b6d..f78453e9 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,Price,Registered in,Processor,RAM (GB),Storage Size (MB),Rate,Range,Processor Rate,Processor Range,RAM Rate,RAM Range,Data Storage Rate,Data Storage Range,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 1 Size,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 Nov 13 17:20:42 2018,p1ml,0,0,0.8,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,,,,,,,,,,,,,,,,,,,,, +Type,Chassis,Tag 1,Tag 2,Tag 3,Serial Number,Model,Manufacturer,Registered in,Price,Processor,RAM (GB),Data Storage Size (MB),Rate,Range,Processor Rate,Processor Range,RAM Rate,RAM Range,Data Storage Rate,Data Storage Range,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 Mar 5 19:54:18 2019,,p1ml,0,0,0.8,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,,,,,,,,,,,,,,,,,,,, diff --git a/tests/files/computer-monitor.csv b/tests/files/computer-monitor.csv index 26213062..0c529700 100644 --- a/tests/files/computer-monitor.csv +++ b/tests/files/computer-monitor.csv @@ -1,2 +1,2 @@ -Type,Tag 1,Tag 2,Tag 3,Serial Number,Model,Manufacturer,Price,Registered in -ComputerMonitor,,,,cn0fp446728728541c8s,1707fpf,dell,,Wed Oct 24 20:57:18 2018 +Type,Chassis,Tag 1,Tag 2,Tag 3,Serial Number,Model,Manufacturer,Registered in,Price +ComputerMonitor,,,,,cn0fp446728728541c8s,1707fpf,dell,Wed Oct 24 20:57:18 2018 \ No newline at end of file diff --git a/tests/files/keyboard.csv b/tests/files/keyboard.csv index dd279133..097a48fc 100644 --- a/tests/files/keyboard.csv +++ b/tests/files/keyboard.csv @@ -1,2 +1,2 @@ -Type,Tag 1,Tag 2,Tag 3,Serial Number,Model,Manufacturer,Price,Registered in -Keyboard,,,,bar,foo,baz,,Wed Oct 24 21:01:48 2018 +Type,Chassis,Tag 1,Tag 2,Tag 3,Serial Number,Model,Manufacturer,Registered in,Price +Keyboard,,,,,bar,foo,baz,Wed Oct 24 21:01:48 2018 diff --git a/tests/files/multiples_devices.csv b/tests/files/multiples_devices.csv new file mode 100644 index 00000000..6a093d0d --- /dev/null +++ b/tests/files/multiples_devices.csv @@ -0,0 +1,17 @@ +Type,Chassis,Tag 1,Tag 2,Tag 3,Serial Number,Model,Manufacturer,Registered in,Price,Processor,RAM (GB),Data Storage Size (MB),Rate,Range,Processor Rate,Processor Range,RAM Rate,RAM Range,Data Storage Rate,Data Storage Range,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 +Laptop,Netbook,,,,b8oaas048286,1001pxd,asustek computer inc.,Wed Mar 6 18:22:05 2019,,intel atom cpu n455 @ 1.66ghz,1024,238475,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium,,,,,,,,,,,,,,,,,,,,,"GraphicCard 5: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None",,,,256,,,,,"Motherboard 10: model 1001pxd, S/N eee0123456789",eee0123456789,eee0123456789,eee0123456789,"NetworkAdapter 2: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c8",74:2f:68:8b:fd:c8,74:2f:68:8b:fd:c8,74:2f:68:8b:fd:c8,"NetworkAdapter 3: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7c",14:da:e9:42:f6:7c,14:da:e9:42:f6:7c,14:da:e9:42:f6:7c,"Processor 4: model intel atom cpu n455 @ 1.66ghz, S/N None",,,,1,1.667,,,,,"RamModule 8: model None, S/N None",,,,1024,667,,,,,,,,,,,,,"SoundCard 6: model nm10/ich7 family high definition audio controller, S/N None",,,,"SoundCard 7: model usb 2.0 uvc vga webcam, S/N 0x0001",0x0001,0x0001,0x0001 +NetworkAdapter,,,,,74:2f:68:8b:fd:c8,ar9285 wireless network adapter,qualcomm atheros,Wed Mar 6 18:22:05 2019,,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium +NetworkAdapter,,,,,14:da:e9:42:f6:7c,ar8152 v2.0 fast ethernet,qualcomm atheros,Wed Mar 6 18:22:05 2019,,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium +Processor,,,,,,intel atom cpu n455 @ 1.66ghz,intel corp.,Wed Mar 6 18:22:05 2019,,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium +GraphicCard,,,,,,atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller,intel corporation,Wed Mar 6 18:22:05 2019,,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium +SoundCard,,,,,,nm10/ich7 family high definition audio controller,intel corporation,Wed Mar 6 18:22:05 2019,,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium +SoundCard,,,,,0x0001,usb 2.0 uvc vga webcam,azurewave,Wed Mar 6 18:22:05 2019,,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium +RamModule,,,,,,,,Wed Mar 6 18:22:05 2019,,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium +HardDrive,,,,,e2024242cv86hj,hts54322,hitachi,Wed Mar6 18:22:05 2019,,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium +Motherboard,,,,,eee0123456789,1001pxd,asustek computer inc.,Wed Mar 6 18:22:05 2019,,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium +Desktop,Microtower,,,,d1s,d1ml,d1mr,Wed Mar 6 18:22:06 2019,,p1ml,0,0,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low,,,,,,,,,,,,,,,,,,,,,"GraphicCard 12: model gc1ml, S/N gc1s",gc1s,gc1s,gc1s,,,,,,,,,,,,,,,,,,"Processor 14: model p1ml, S/N p1s",p1s,p1s,p1s,,1.6,,,,,"RamModule 13: model rm1ml, S/N rm1s",rm1s,rm1s,rm1s,,1333,,,,,,,,,,,,,,,,,,,, +GraphicCard,,,,,gc1s,gc1ml,gc1mr,Wed Mar 6 18:22:06 2019,,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low +RamModule,,,,,rm1s,rm1ml,rm1mr,Wed Mar 6 18:22:06 2019,,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low +Processor,,,,,p1s,p1ml,p1mr,Wed Mar 6 18:22:06 2019,,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low +Keyboard,,,,,bar,foo,baz,Wed Mar 6 18:22:06 2019, +ComputerMonitor,,,,,cn0fp446728728541c8s,1707fpf,dell,Wed Mar 6 18:22:06 2019, diff --git a/tests/files/real-eee-1001pxd.csv b/tests/files/real-eee-1001pxd.csv index 2debf295..ef09a24b 100644 --- a/tests/files/real-eee-1001pxd.csv +++ b/tests/files/real-eee-1001pxd.csv @@ -1,2 +1,2 @@ -Type,Chassis,Tag 1,Tag 2,Tag 3,Serial Number,Model,Manufacturer,Price,Registered in,Processor,RAM (GB),Storage Size (MB),Rate,Range,Processor Rate,Processor Range,RAM Rate,RAM Range,Data Storage Rate,Data Storage Range,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,Motherboard 1 Slots,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 1 Size,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 -Laptop,Netbook,,,,b8oaas048286,1001pxd,asustek computer inc.,,Thu Oct 25 10:26:02 2018,intel atom cpu n455 @ 1.66ghz,1024,238475,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium,,,,,,,,,,,,,,,,,,,,,"GraphicCard 5: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None",,,,256,,,,,"Motherboard 10: model 1001pxd, S/N eee0123456789",eee0123456789,eee0123456789,eee0123456789,2,"NetworkAdapter 2: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c8",74:2f:68:8b:fd:c8,74:2f:68:8b:fd:c8,74:2f:68:8b:fd:c8,"NetworkAdapter 3: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7c",14:da:e9:42:f6:7c,14:da:e9:42:f6:7c,14:da:e9:42:f6:7c,"Processor 4: model intel atom cpu n455 @ 1.66ghz, S/N None",,,,1,1.667,,,,,"RamModule 8: model None, S/N None",,,,1024,667,1024,,,,,,,,,,,,,"SoundCard 6: model nm10/ich7 family high definition audio controller, S/N None",,,,"SoundCard 7: model usb 2.0 uvc vga webcam, S/N 0x0001",0x0001,0x0001,0x0001 +Type,Chassis,Tag 1,Tag 2,Tag 3,Serial Number,Model,Manufacturer,Registered in,Price,Processor,RAM (GB),Data Storage Size (MB),Rate,Range,Processor Rate,Processor Range,RAM Rate,RAM Range,Data Storage Rate,Data Storage Range,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 +Laptop,Netbook,,,,b8oaas048286,1001pxd,asustek computer inc.,Tue Mar 5 19:56:08 2019,,intel atom cpu n455 @ 1.66ghz,1024,238475,1.73,Very low,1.0,Very low,1.53,Very low,3.76,Medium,,,,,,,,,,,,,,,,,,,,,"GraphicCard 5: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None",,,,256,,,,,"Motherboard 10: model 1001pxd, S/N eee0123456789",eee0123456789,eee0123456789,eee0123456789,"NetworkAdapter 2: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c8",74:2f:68:8b:fd:c8,74:2f:68:8b:fd:c8,74:2f:68:8b:fd:c8,"NetworkAdapter 3: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7c",14:da:e9:42:f6:7c,14:da:e9:42:f6:7c,14:da:e9:42:f6:7c,"Processor 4: model intel atom cpu n455 @ 1.66ghz, S/N None",,,,1,1.667,,,,,"RamModule 8: model None, S/N None",,,,1024,667,,,,,,,,,,,,,"SoundCard 6: model nm10/ich7 family high definition audio controller, S/N None",,,,"SoundCard 7: model usb 2.0 uvc vga webcam, S/N 0x0001",0x0001,0x0001,0x0001 diff --git a/tests/test_reports.py b/tests/test_reports.py index aa6baf59..fe053760 100644 --- a/tests/test_reports.py +++ b/tests/test_reports.py @@ -3,10 +3,8 @@ from datetime import datetime from io import StringIO from pathlib import Path -import pytest - from ereuse_devicehub.client import UserClient -from ereuse_devicehub.resources.documents import documents as docs +from ereuse_devicehub.resources.documents import documents from ereuse_devicehub.resources.event.models import Snapshot from tests.conftest import file @@ -16,24 +14,26 @@ def test_export_basic_snapshot(user: UserClient): Test export device information in a csv file """ snapshot, _ = user.post(file('basic.snapshot'), res=Snapshot) - csv_str, _ = user.get(res=docs.DocumentDef.t, + 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) 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) fixture_csv = list(obj_csv) - assert isinstance(datetime.strptime(export_csv[1][9], '%c'), datetime), \ + assert isinstance(datetime.strptime(export_csv[1][8], '%c'), datetime), \ 'Register in field is not a datetime' - fixture_csv[1] = fixture_csv[1][:9] + fixture_csv[1][10:] - export_csv[1] = export_csv[1][:9] + export_csv[1][10:] # 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' @@ -43,25 +43,26 @@ def test_export_full_snapshot(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) - csv_str, _ = user.get(res=docs.DocumentDef.t, + 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) 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) fixture_csv = list(obj_csv) - assert isinstance(datetime.strptime(export_csv[1][9], '%c'), datetime), \ + assert isinstance(datetime.strptime(export_csv[1][8], '%c'), datetime), \ 'Register in field is not a datetime' # Pop dates fields from csv lists to compare them - fixture_csv[1] = fixture_csv[1][:9] + fixture_csv[1][10:] - export_csv[1] = export_csv[1][:9] + export_csv[1][10:] + 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' @@ -71,7 +72,7 @@ def test_export_empty(user: UserClient): """ Test to check works correctly exporting csv without any information (no snapshot) """ - csv_str, _ = user.get(res=docs.DocumentDef.t, + csv_str, _ = user.get(res=documents.DocumentDef.t, accept='text/csv', item='devices/') f = StringIO(csv_str) @@ -86,7 +87,7 @@ def test_export_computer_monitor(user: UserClient): Test a export device type computer monitor """ snapshot, _ = user.post(file('computer-monitor.snapshot'), res=Snapshot) - csv_str, _ = user.get(res=docs.DocumentDef.t, + csv_str, _ = user.get(res=documents.DocumentDef.t, item='devices/', accept='text/csv', query=[('filter', {'type': ['ComputerMonitor']})]) @@ -112,7 +113,7 @@ def test_export_keyboard(user: UserClient): Test a export device type keyboard """ snapshot, _ = user.post(file('keyboard.snapshot'), res=Snapshot) - csv_str, _ = user.get(res=docs.DocumentDef.t, + csv_str, _ = user.get(res=documents.DocumentDef.t, item='devices/', accept='text/csv', query=[('filter', {'type': ['Keyboard']})]) @@ -132,25 +133,37 @@ def test_export_keyboard(user: UserClient): assert fixture_csv[1] == export_csv[1], 'Component information are not equal' -@pytest.mark.xfail(reason='Develop test') def test_export_multiple_devices(user: UserClient): """ - Test a export multiple devices with different components and information + Test a export multiple devices (Computers and other types) with different information """ - pass + # Post all devices snapshots + snapshot_pc, _ = user.post(file('real-eee-1001pxd.snapshot.11'), res=Snapshot) + snapshot_empty, _ = user.post(file('basic.snapshot'), res=Snapshot) + snapshot_keyboard, _ = user.post(file('keyboard.snapshot'), res=Snapshot) + snapshot_monitor, _ = user.post(file('computer-monitor.snapshot'), res=Snapshot) + # need query param?? + csv_str, _ = user.get(res=documents.DocumentDef.t, + item='devices/', + accept='text/csv') + f = StringIO(csv_str) + obj_csv = csv.reader(f, f) + export_csv = list(obj_csv) -@pytest.mark.xfail(reason='Develop test') -def test_export_only_components(user: UserClient): - """ - Test a export only components - """ - pass + # Open fixture csv and transform to list + with Path(__file__).parent.joinpath('files').joinpath('multiples_devices.csv').open() \ + as csv_file: + obj_csv = csv.reader(csv_file) + fixture_csv = list(obj_csv) + assert fixture_csv[0] == export_csv[0], 'Headers are not equal' -@pytest.mark.xfail(reason='Develop test') -def test_export_computers_and_components(user: UserClient): - """ - Test a export multiple devices (computers and independent components) - """ - pass + max_range = max(len(export_csv), len(fixture_csv)) - 1 + # check if all devices information is correct + for i in range(1, max_range): + if isinstance(datetime.strptime(export_csv[i][8], '%c'), datetime): + export_csv[i] = export_csv[i][:8] + export_csv[i][9:] + fixture_csv[i] = fixture_csv[i][:8] + fixture_csv[i][9:] + + assert fixture_csv[i] == export_csv[i], 'Some fields are not equal'