From 3a6032c17d9493d16466d895c116ae0d3242e451 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 18 Jul 2022 11:28:02 +0200 Subject: [PATCH] add test for new placeholder from a lot adding from form --- tests/test_render_2_0.py | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index 23ddf2d9..944995e6 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -1942,7 +1942,7 @@ def test_placeholder_log_excel_update(user3: UserClientFlask): @pytest.mark.mvp @pytest.mark.usefixtures(conftest.app_context.__name__) -def test_add_placeholder_excel_to_lot(user3: UserClientFlask): +def test_add_placeholder_excel_from_lot(user3: UserClientFlask): user3.get('/inventory/lot/add/') lot_name = 'lot1' data = { @@ -1973,3 +1973,41 @@ def test_add_placeholder_excel_to_lot(user3: UserClientFlask): assert dev.placeholder.info == 'Good conditions' assert dev.placeholder.pallet == '24A' assert dev.placeholder.id_device_supplier == 'TTT' + assert len(lot.devices) == 3 + + +@pytest.mark.mvp +@pytest.mark.usefixtures(conftest.app_context.__name__) +def test_add_new_placeholder_from_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() + assert len(lot.devices) == 0 + lot_id = lot.id + + uri = f'/inventory/lot/{lot_id}/device/add/' + + user3.get(uri) + data = { + 'csrf_token': generate_csrf(), + 'type': "Laptop", + 'phid': 'ace', + 'serial_number': "AAAAB", + 'model': "LC27T55", + 'manufacturer': "Samsung", + 'generation': 1, + 'weight': 0.1, + 'height': 0.1, + 'depth': 0.1, + 'id_device_supplier': "b2", + } + user3.post(uri, data=data) + dev = Device.query.one() + assert dev.hid == 'laptop-samsung-lc27t55-aaaab' + assert dev.placeholder.phid == 'ace' + assert len(lot.devices) == 1