2018-10-18 15:36:14 +00:00
|
|
|
import csv
|
2018-10-23 15:36:53 +00:00
|
|
|
from io import StringIO
|
|
|
|
from pathlib import Path
|
2018-10-18 15:36:14 +00:00
|
|
|
|
|
|
|
import pytest
|
2018-10-23 15:36:53 +00:00
|
|
|
# [(t, l) for t,l in zip(test_csv[0], list_csv[0]) if t != l]
|
2018-10-18 15:36:14 +00:00
|
|
|
|
2018-10-11 16:19:33 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2018-10-18 15:36:14 +00:00
|
|
|
def test_export_endpoint(user: UserClient):
|
2018-10-11 16:19:33 +00:00
|
|
|
snapshot, _ = user.post(file('basic.snapshot'), res=Snapshot)
|
2018-10-23 15:36:53 +00:00
|
|
|
# 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'
|
2018-10-11 16:19:33 +00:00
|
|
|
|
2018-10-23 15:36:53 +00:00
|
|
|
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
|