From c23c16eee83decbc3f6056114dced3a76487c37c Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 21 Oct 2020 22:33:58 +0200 Subject: [PATCH] fixing test basic --- tests/files/basic.csv | 4 ++-- tests/test_documents.py | 50 ++++++++--------------------------------- 2 files changed, 11 insertions(+), 43 deletions(-) diff --git a/tests/files/basic.csv b/tests/files/basic.csv index fc2d85d8..b938800c 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;Hardware ID;Device Type;Device Chassis;Serial Number;Model;Manufacturer;Registered in;Registered (process);Updated in (software);Updated in (web);Physical state;Trading state;Price;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;Erasure DataStorage 1;Erasure DataStorage 1 Serial Number;Erasure DataStorage 1 Size;Erasure DataStorage 1 Software;Erasure DataStorage 1 Result;Erasure DataStorage 1 Type;Erasure DataStorage 1 Method;Erasure DataStorage 1 Elapsed;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;Erasure DataStorage 2;Erasure DataStorage 2 Serial Number;Erasure DataStorage 2 Size;Erasure DataStorage 2 Software;Erasure DataStorage 2 Result;Erasure DataStorage 2 Type;Erasure DataStorage 2 Method;Erasure DataStorage 2 Elapsed;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;Erasure DataStorage 3;Erasure DataStorage 3 Serial Number;Erasure DataStorage 3 Size;Erasure DataStorage 3 Software;Erasure DataStorage 3 Result;Erasure DataStorage 3 Type;Erasure DataStorage 3 Method;Erasure DataStorage 3 Elapsed;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;Erasure DataStorage 4;Erasure DataStorage 4 Serial Number;Erasure DataStorage 4 Size;Erasure DataStorage 4 Software;Erasure DataStorage 4 Result;Erasure DataStorage 4 Type;Erasure DataStorage 4 Method;Erasure DataStorage 4 Elapsed;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;Benchmark RamSysbench (points) +1;http://localhost/devices/1;;;;;;;;;;desktop-d1mr-d1ml-d1s;Desktop;Microtower;d1s;d1ml;d1mr;Wed Oct 21 22:18:50 2020;Workbench 11.0;2020-10-21 22:18:50.219900+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/test_documents.py b/tests/test_documents.py index 3f7671b4..5bf8c1bb 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -88,53 +88,20 @@ 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' - - -@pytest.mark.mvp -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=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][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][: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][20:] == export_csv[1][20:], 'Computer information are not equal' @pytest.mark.mvp def test_export_extended(app: Devicehub, user: UserClient): @@ -164,12 +131,13 @@ def test_export_extended(app: Devicehub, user: UserClient): obj_csv = csv.reader(csv_file, delimiter=';', quotechar='"') fixture_csv = list(obj_csv) + assert isinstance(datetime.strptime(export_csv[1][17], '%c'), datetime), \ + 'Register in field is not a datetime' + assert fixture_csv[0] == export_csv[0], 'Headers are not equal' assert fixture_csv[1][:17] == export_csv[1][:17], 'Computer information are not equal' assert fixture_csv[1][20:80] == export_csv[1][20:80], 'Computer information are not equal' - assert fixture_csv[1][81:104] == export_csv[1][81:104], 'Computer information are not equal' - assert fixture_csv[1][105:128] == export_csv[1][105:128], 'Computer information are not equal' - assert fixture_csv[1][129:] == export_csv[1][129:], 'Computer information are not equal' + assert fixture_csv[1][81:] == export_csv[1][81:], 'Computer information are not equal' assert fixture_csv[2][:17] == export_csv[2][:17], 'Computer information are not equal' assert fixture_csv[2][20:80] == export_csv[2][20:80], 'Computer information are not equal' assert fixture_csv[2][81:104] == export_csv[2][81:104], 'Computer information are not equal'