From 83ea86705d870667f646695e8c41059a0629c5c2 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 18 Jul 2022 10:56:05 +0200 Subject: [PATCH] test for add new placeholder in a lot --- tests/test_render_2_0.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index 96415935..23ddf2d9 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -1938,3 +1938,38 @@ def test_placeholder_log_excel_update(user3: UserClientFlask): assert "Excel" in body assert "placeholder_test.xls" in body assert "placeholder_test.csv" in body + + +@pytest.mark.mvp +@pytest.mark.usefixtures(conftest.app_context.__name__) +def test_add_placeholder_excel_to_lot(user3: UserClientFlask): + user3.get('/inventory/lot/add/') + lot_name = 'lot1' + data = { + 'name': lot_name, + 'csrf_token': generate_csrf(), + } + user3.post('/inventory/lot/add/', data=data) + lot = Lot.query.filter_by(name=lot_name).one() + lot_id = lot.id + + uri = f'/inventory/lot/{lot_id}/upload-placeholder/' + body, status = user3.get(uri) + assert status == '200 OK' + assert "Upload Placeholder" in body + + file_path = Path(__file__).parent.joinpath('files').joinpath('placeholder_test.xls') + with open(file_path, 'rb') as excel: + data = { + 'csrf_token': generate_csrf(), + 'type': "Laptop", + 'placeholder_file': excel, + } + user3.post(uri, data=data, content_type="multipart/form-data") + assert Device.query.count() == 3 + dev = Device.query.first() + assert dev.hid == 'laptop-sony-vaio-12345678' + assert dev.placeholder.phid == 'a123' + assert dev.placeholder.info == 'Good conditions' + assert dev.placeholder.pallet == '24A' + assert dev.placeholder.id_device_supplier == 'TTT'