From ad9b9e4e83f6ecc98c08b29a48740d5d65a2ceb5 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 21 Sep 2022 12:04:34 +0200 Subject: [PATCH] add test exports actions erasure --- ereuse_devicehub/inventory/views.py | 1 + tests/test_render_2_0.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index c186b469..f5fb87d6 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -922,6 +922,7 @@ class ExportsView(View): args = request.args.get('ids') ids = args.split(',') if args else [] + ids = [id.strip() for id in ids] query = EraseBasic.query.filter_by(author=g.user) query = query.filter(EraseBasic.id.in_(ids)) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index 227db4cc..4b610068 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -260,6 +260,20 @@ def test_export_certificates(user3: UserClientFlask): assert 'hts54322' in body +@pytest.mark.mvp +@pytest.mark.usefixtures(conftest.app_context.__name__) +def test_export_actions_erasure(user3: UserClientFlask): + snap = create_device(user3, 'erase-sectors-2-hdd.snapshot') + ids = [str(ac.id) for ac in snap.actions if ac.type == 'EraseBasic'] + ids = ",".join(ids) + uri = "/inventory/export/actions_erasures/?ids={id}".format(id=ids) + + body, status = user3.get(uri) + assert status == '200 OK' + assert "WD-WCAV27984668" in body + assert "WD-WCAV29008961" in body + + @pytest.mark.mvp @pytest.mark.usefixtures(conftest.app_context.__name__) def test_labels(user3: UserClientFlask):