add test for new placeholder from a lot adding from form

This commit is contained in:
Cayo Puigdefabregas 2022-07-18 11:28:02 +02:00
parent 26b322ba70
commit 3a6032c17d

View file

@ -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