Add fixtures csv files and exports tests

This commit is contained in:
JNadeu 2018-10-24 21:09:54 +02:00
parent 97289cdfea
commit c299656f05
7 changed files with 101 additions and 58 deletions

View File

@ -1,39 +0,0 @@
from typing import Set
from sqlalchemy import func
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.resources.event.models import Price, Event, Trade
ids = {1,2,3}
def export(devices_id: Set[str]):
# todo get the last event of device
last_event = Event.end_time.
devices = Device.id.in_(ids)
total_value_query = db.session.query(Price, func.sum(Price.price).label('total'))\
.filter(devices)\
.join(Price.device)\
.filter(last_event)
# todo hacer query para obtener el price
query(func.max(end_time)).join(Price.devices).filter(Device_id==id).ordey_by(Price.end_time).limit()
total_price_query = query()
value = total_value_query.one()
value['total']
#
db.session.query(Price, (Price.price / total_value_query).label('asdfas'))
trade_orgs_q = db.session.query(Trade, func.sum(Trade.org_id)).filter(devices).join(Trade.devices).filter(last_event)
# execute query
value = trade_orgs_q.scalar()

View File

@ -1,5 +1,2 @@
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
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,Display 2,Display 2 Manufacturer,Display 2 Model,Display 2 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,ComputerChassis.Microtower,,,,d1s,d1ml,d1mr,,Wed Oct 24 20:19:44 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,,,,,,,,,,,,,,,,,,,,,

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 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 Display 2 Display 2 Manufacturer Display 2 Model Display 2 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
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 Desktop ComputerChassis.Microtower d1s d1ml d1mr Wed Oct 24 20:19:44 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
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

View File

@ -0,0 +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
1 Type Tag 1 Tag 2 Tag 3 Serial Number Model Manufacturer Price Registered in
2 ComputerMonitor cn0fp446728728541c8s 1707fpf dell Wed Oct 24 20:57:18 2018

View File

@ -0,0 +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,Display 2,Display 2 Manufacturer,Display 2 Model,Display 2 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,ComputerChassis.Netbook,,,,b8oaas048286,1001pxd,asustek computer inc.,,Wed Oct 24 20:42:19 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
1 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 Display 2 Display 2 Manufacturer Display 2 Model Display 2 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
2 Laptop ComputerChassis.Netbook b8oaas048286 1001pxd asustek computer inc. Wed Oct 24 20:42:19 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

2
tests/files/keyboard.csv Normal file
View File

@ -0,0 +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
1 Type Tag 1 Tag 2 Tag 3 Serial Number Model Manufacturer Price Registered in
2 Keyboard bar foo baz Wed Oct 24 21:01:48 2018

View File

@ -2,37 +2,116 @@ 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
from ereuse_devicehub.resources.event.models import Snapshot
from tests.conftest import file
def test_export_endpoint(user: UserClient):
def test_export_basic_snapshot(user: UserClient):
"""
Test export device information in a csv file
"""
snapshot, _ = user.post(file('basic.snapshot'), res=Snapshot)
# 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:
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)
list_csv = list(obj_csv)
assert test_csv == list_csv, 'Csv files are different'
fixture_csv = list(obj_csv)
# Pop(datetime) field d[1x][9]
fixture_csv[1] = fixture_csv[1][:9] + fixture_csv[1][10:]
export_csv[1] = export_csv[1][:9] + export_csv[1][10:]
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert fixture_csv[1] == export_csv[1], 'Computer information are not equal'
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=Device, accept='text/csv')
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('full-real-eee.csv').open() as csv_file:
obj_csv = csv.reader(csv_file)
fixture_csv = list(obj_csv)
# todo one pop for each devices
# One pop(datetime) fields d[1x][9]
fixture_csv[1] = fixture_csv[1][:9] + fixture_csv[1][10:]
export_csv[1] = export_csv[1][:9] + export_csv[1][10:]
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert fixture_csv[1] == export_csv[1], 'Computer information are not equal'
def test_export_empty(user: UserClient):
"""
Test to check works correctly exporting csv without any information
Test to check works correctly exporting csv without any information (no snapshot)
"""
pass
csv_str, _ = user.get(res=Device, accept='text/csv')
f = StringIO(csv_str)
obj_csv = csv.reader(f, f)
export_csv = list(obj_csv)
assert len(export_csv) == 0, 'Csv is not empty'
def test_export_full_snaphsot(user: UserClient):
def test_export_computer_monitor(user: UserClient):
"""
Test a export device with all fields
:return:
Test a export device type computer monitor
"""
snapshot, _ = user.post(file('computer-monitor.snapshot'), res=Snapshot)
csv_str, _ = user.get(res=Device, accept='text/csv')
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('computer-monitor.csv').open() as csv_file:
obj_csv = csv.reader(csv_file)
fixture_csv = list(obj_csv)
# One pop(datetime) fields
fixture_csv[1] = fixture_csv[1][:8]
export_csv[1] = export_csv[1][:8]
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert fixture_csv[1] == export_csv[1], 'Component information are not equal'
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=Device, accept='text/csv')
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('keyboard.csv').open() as csv_file:
obj_csv = csv.reader(csv_file)
fixture_csv = list(obj_csv)
# One pop(datetime) fields
fixture_csv[1] = fixture_csv[1][:8]
export_csv[1] = export_csv[1][:8]
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert fixture_csv[1] == export_csv[1], 'Component information are not equal'
def test_export_multiple_devices(user: UserClient):
"""
Test a export multiple devices with different components and information
"""
# todo test multiple devices
pass