add basic.csv file to use in test_reports

This commit is contained in:
JNadeu 2018-10-23 17:36:53 +02:00
parent 654edf35a1
commit 50a365b4bf
2 changed files with 30 additions and 8 deletions

5
tests/files/basic.csv Normal file
View file

@ -0,0 +1,5 @@
Type,Chassis,Tag 1,Tag 2,Tag 3,Serial Number,Price,Model,Manufacturer,Registered in ,Processor,RAM (GB),Size (MB),Rate,Range,Processor Rate,Processor Range,RAM Rate,RAM Range,Data Storage Rate,Data Storage Range,Component 1 Serial Number,Component 2 Serial Number,Component 3 Serial Number,RamModule 1 Serial Number,RamModule 2 Serial Number,RamModule 3 Serial Number,GraphicCard 1 Serial Number,GraphicCard 2 Serial Number,GraphicCard 3 Serial Number,Motherboard 1 Serial Number,Motherboard 2 Serial Number,Motherboard 3 Serial Number,SoundCard 1 Serial Number,SoundCard 2 Serial Number,SoundCard 3 Serial Number,Display 1 Serial Number,Display 2 Serial Number,Display 3 Serial Number,NetworkAdapter 1 Serial Number,NetworkAdapter 2 Serial Number,NetworkAdapter 3 Serial Number,DataStorage 1 Serial Number,DataStorage 2 Serial Number,DataStorage 3 Serial Number,SolidStateDrive 1 Serial Number,SolidStateDrive 2 Serial Number,SolidStateDrive 3 Serial Number,HardDrive 1 Serial Number,HardDrive 2 Serial Number,HardDrive 3 Serial Number,Processor 1 Serial Number
Desktop,ComputerChassis.Microtower,,,,d1s,,d1ml,d1mr,2018-10-22 12:53:17.180047+02:00,p1ml,0,0,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low,,,,rm1s,,,gc1s,,,,,,,,,,,,,,,,,,,,,,,,p1s
GraphicCard,,,,gc1s,,gc1ml,gc1mr,2018-10-22 12:53:17.163571+02:00,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low
RamModule,,,,rm1s,,rm1ml,rm1mr,2018-10-22 12:53:17.168983+02:00,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low
Processor,,,,p1s,,p1ml,p1mr,2018-10-22 12:53:17.173623+02:00,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low
1 Type,Chassis,Tag 1,Tag 2,Tag 3,Serial Number,Price,Model,Manufacturer,Registered in ,Processor,RAM (GB),Size (MB),Rate,Range,Processor Rate,Processor Range,RAM Rate,RAM Range,Data Storage Rate,Data Storage Range,Component 1 Serial Number,Component 2 Serial Number,Component 3 Serial Number,RamModule 1 Serial Number,RamModule 2 Serial Number,RamModule 3 Serial Number,GraphicCard 1 Serial Number,GraphicCard 2 Serial Number,GraphicCard 3 Serial Number,Motherboard 1 Serial Number,Motherboard 2 Serial Number,Motherboard 3 Serial Number,SoundCard 1 Serial Number,SoundCard 2 Serial Number,SoundCard 3 Serial Number,Display 1 Serial Number,Display 2 Serial Number,Display 3 Serial Number,NetworkAdapter 1 Serial Number,NetworkAdapter 2 Serial Number,NetworkAdapter 3 Serial Number,DataStorage 1 Serial Number,DataStorage 2 Serial Number,DataStorage 3 Serial Number,SolidStateDrive 1 Serial Number,SolidStateDrive 2 Serial Number,SolidStateDrive 3 Serial Number,HardDrive 1 Serial Number,HardDrive 2 Serial Number,HardDrive 3 Serial Number,Processor 1 Serial Number
2 Desktop,ComputerChassis.Microtower,,,,d1s,,d1ml,d1mr,2018-10-22 12:53:17.180047+02:00,p1ml,0,0,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low,,,,rm1s,,,gc1s,,,,,,,,,,,,,,,,,,,,,,,,p1s
3 GraphicCard,,,,gc1s,,gc1ml,gc1mr,2018-10-22 12:53:17.163571+02:00,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low
4 RamModule,,,,rm1s,,rm1ml,rm1mr,2018-10-22 12:53:17.168983+02:00,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low
5 Processor,,,,p1s,,p1ml,p1mr,2018-10-22 12:53:17.173623+02:00,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low

View file

@ -1,6 +1,9 @@
import csv
from io import StringIO
from pathlib import Path
import pytest
# [(t, l) for t,l in zip(test_csv[0], list_csv[0]) if t != l]
from ereuse_devicehub.client import UserClient
from ereuse_devicehub.resources.device.models import Device
@ -10,12 +13,26 @@ from tests.conftest import file
def test_export_endpoint(user: UserClient):
snapshot, _ = user.post(file('basic.snapshot'), res=Snapshot)
device_type = snapshot['device']['type']
csv_list, _ = user.get(res=Device, accept='text/csv')
read_csv = csv.reader(csv_list, delimiter=',')
dates = []
for row in read_csv:
date = row[0]
dates.append(date)
# device_type = snapshot['device']['type']
csv_str, _ = user.get(res=Device, accept='text/csv')
f = StringIO(csv_str)
obj_csv = csv.reader(f, f)
test_csv = list(obj_csv)
with Path(__file__).parent.joinpath('files').joinpath('testcsv.csv').open() as csv_file:
obj_csv = csv.reader(csv_file)
list_csv = list(obj_csv)
assert test_csv == list_csv, 'Csv files are different'
assert dates[1] == device_type, 'Device type are not equal'
def test_export_empty(user: UserClient):
"""
Test to check works correctly exporting csv without any information
"""
pass
def test_export_full_snaphsot(user: UserClient):
"""
Test a export device with all fields
:return:
"""
pass