diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py
index 7d1bbc86..8c7569eb 100644
--- a/ereuse_devicehub/inventory/views.py
+++ b/ereuse_devicehub/inventory/views.py
@@ -829,6 +829,7 @@ class ExportsView(View):
'certificates': self.erasure,
'lots': self.lots_export,
'devices_lots': self.devices_lots_export,
+ 'obada_standard': self.obada_standard_export,
'snapshot': self.snapshot,
}
@@ -872,6 +873,34 @@ class ExportsView(View):
return self.response_csv(data, "export.csv")
+ def obada_standard_export(self):
+ """Get device information for Obada Standard."""
+ data = StringIO()
+ cw = csv.writer(
+ data,
+ delimiter=';',
+ lineterminator="\n",
+ quotechar='"',
+ quoting=csv.QUOTE_ALL,
+ )
+
+ cw.writerow(['Manufacturer', 'Model', 'Serial Number'])
+
+ for device in self.find_devices():
+ if device.placeholder:
+ if not device.placeholder.binding:
+ continue
+ device = device.placeholder.binding
+
+ d = [
+ device.manufacturer,
+ device.model,
+ device.serial_number,
+ ]
+ cw.writerow(d)
+
+ return self.response_csv(data, "obada_standard.csv")
+
def metrics(self):
"""Get device query and put information in csv format."""
data = StringIO()
diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html
index 3bb32fc5..8f14446a 100644
--- a/ereuse_devicehub/templates/inventory/device_list.html
+++ b/ereuse_devicehub/templates/inventory/device_list.html
@@ -242,6 +242,12 @@
{% endif %}
+
+
+
+ Obada Standard Spreadsheet
+
+
diff --git a/tests/files/export_obada_standard.csv b/tests/files/export_obada_standard.csv
new file mode 100644
index 00000000..d83e4e2c
--- /dev/null
+++ b/tests/files/export_obada_standard.csv
@@ -0,0 +1,2 @@
+"Manufacturer";"Model";"Serial Number"
+"asustek computer inc.";"1001pxd";"b8oaas048285"
diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py
index 9318d3b7..fbc8307c 100644
--- a/tests/test_render_2_0.py
+++ b/tests/test_render_2_0.py
@@ -1,11 +1,10 @@
import datetime
-import pytest
import json
-
from io import BytesIO
from pathlib import Path
from uuid import UUID
+import pytest
from flask import g
from flask.testing import FlaskClient
from flask_wtf.csrf import generate_csrf
@@ -279,6 +278,28 @@ def test_export_devices(user3: UserClientFlask):
), 'Computer information are not equal'
+@pytest.mark.mvp
+@pytest.mark.usefixtures(conftest.app_context.__name__)
+def test_export_obada_standard(user3: UserClientFlask):
+ snap = create_device(user3, 'real-eee-1001pxd.snapshot.12.json')
+ uri = "/inventory/export/obada_standard/?ids={id}".format(
+ id=snap.device.devicehub_id
+ )
+
+ body, status = user3.get(uri)
+ assert status == '200 OK'
+
+ export_csv = [line.split(";") for line in body.split("\n")]
+
+ with Path(__file__).parent.joinpath('files').joinpath(
+ 'export_obada_standard.csv'
+ ).open() as csv_file:
+ fixture_csv = [line.split(";") for line in csv_file.read().split("\n")]
+
+ assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
+ assert fixture_csv[1] == export_csv[1], 'body are not equal'
+
+
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_export_metrics(user3: UserClientFlask):