fix tests

This commit is contained in:
Cayo Puigdefabregas 2022-10-05 13:45:06 +02:00
parent 74dde2e626
commit c97ef94101
5 changed files with 36 additions and 62 deletions

View File

@ -1,4 +1,4 @@
Phid;Model;Manufacturer;Serial Number;Part Number;Id device Supplier;Pallet;Info Model;Manufacturer;Serial Number;Part Number;Id device Supplier;Id device Internal;Pallet;Info
a123;Vaio;Sony;12345678;;TTT;24A;Good conditions Vaio;Sony;12345678;;TTT;AA;24A;Good conditions
a124;Vaio;Sony;12345679;;TTT;24A;Good conditions Vaio;Sony;12345679;;TTT;BB;24A;Good conditions
a125;Vaio;Sony;12345680;;TTT;24A;Good conditions Vaio;Sony;12345680;;TTT;CC;24A;Good conditions

1 Phid Model Manufacturer Serial Number Part Number Id device Supplier Id device Internal Pallet Info
2 a123 Vaio Sony 12345678 TTT AA 24A Good conditions
3 a124 Vaio Sony 12345679 TTT BB 24A Good conditions
4 a125 Vaio Sony 12345680 TTT CC 24A Good conditions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -562,7 +562,6 @@ def test_update_monitor(user3: UserClientFlask):
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Monitor", 'type': "Monitor",
'phid': '1',
'serial_number': "AAAAB", 'serial_number': "AAAAB",
'model': "LCD 43 b", 'model': "LCD 43 b",
'manufacturer': "Samsung", 'manufacturer': "Samsung",
@ -575,8 +574,9 @@ def test_update_monitor(user3: UserClientFlask):
} }
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert status == '200 OK' assert status == '200 OK'
assert 'Error, exist one Placeholder device with this PHID' in body # assert 'Error, exist one Placeholder device with this PHID' in body
dev = Device.query.one() dev = Device.query.all()[0]
assert Device.query.count() == 2
assert dev.type == 'Monitor' assert dev.type == 'Monitor'
assert dev.placeholder.id_device_supplier == "b2" assert dev.placeholder.id_device_supplier == "b2"
assert dev.hid == 'monitor-samsung-lc27t55-aaaab' assert dev.hid == 'monitor-samsung-lc27t55-aaaab'
@ -597,7 +597,6 @@ def test_add_2_monitor(user3: UserClientFlask):
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Monitor", 'type': "Monitor",
'phid': "AAB",
'serial_number': "AAAAB", 'serial_number': "AAAAB",
'model': "LC27T55", 'model': "LC27T55",
'manufacturer': "Samsung", 'manufacturer': "Samsung",
@ -619,7 +618,7 @@ def test_add_2_monitor(user3: UserClientFlask):
assert typ == 'Monitor' assert typ == 'Monitor'
assert dev.placeholder.id_device_supplier == "b1" assert dev.placeholder.id_device_supplier == "b1"
assert dev.hid == 'monitor-samsung-lc27t55-aaaab' assert dev.hid == 'monitor-samsung-lc27t55-aaaab'
assert phid == 'AAB' assert phid == '1'
assert dhid == 'O48N2' assert dhid == 'O48N2'
assert dev.model == 'lc27t55' assert dev.model == 'lc27t55'
assert dev.placeholder.pallet == "l34" assert dev.placeholder.pallet == "l34"
@ -737,35 +736,6 @@ def test_add_with_ammount_laptops(user3: UserClientFlask):
assert Device.query.count() == num assert Device.query.count() == num
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_add_laptop_duplicate(user3: UserClientFlask):
uri = '/inventory/device/add/'
body, status = user3.get(uri)
assert status == '200 OK'
assert "New Device" in body
data = {
'csrf_token': generate_csrf(),
'type': "Laptop",
'phid': 'laptop-asustek_computer_inc-1001pxd-b8oaas048285-14:da:e9:42:f6:7b',
'serial_number': "AAAAB",
'model': "LC27T55",
'manufacturer': "Samsung",
'generation': 1,
'weight': 0.1,
'height': 0.1,
'depth': 0.1,
}
body, status = user3.post(uri, data=data)
assert status == '200 OK'
assert Device.query.count() == 1
body, status = user3.post(uri, data=data)
assert 'Error, exist one Placeholder device with this PHID' in body
assert Device.query.count() == 1
@pytest.mark.mvp @pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__) @pytest.mark.usefixtures(conftest.app_context.__name__)
def test_filter_monitor(user3: UserClientFlask): def test_filter_monitor(user3: UserClientFlask):
@ -1729,7 +1699,7 @@ def test_add_placeholder_excel(user3: UserClientFlask):
assert Device.query.count() == 3 assert Device.query.count() == 3
dev = Device.query.first() dev = Device.query.first()
assert dev.hid == 'laptop-sony-vaio-12345678' assert dev.hid == 'laptop-sony-vaio-12345678'
assert dev.placeholder.phid == 'a123' assert dev.placeholder.phid == '1'
assert dev.placeholder.info == 'Good conditions' assert dev.placeholder.info == 'Good conditions'
assert dev.placeholder.pallet == '24A' assert dev.placeholder.pallet == '24A'
assert dev.placeholder.id_device_supplier == 'TTT' assert dev.placeholder.id_device_supplier == 'TTT'
@ -1755,7 +1725,7 @@ def test_add_placeholder_csv(user3: UserClientFlask):
assert Device.query.count() == 3 assert Device.query.count() == 3
dev = Device.query.first() dev = Device.query.first()
assert dev.hid == 'laptop-sony-vaio-12345678' assert dev.hid == 'laptop-sony-vaio-12345678'
assert dev.placeholder.phid == 'a123' assert dev.placeholder.phid == '1'
assert dev.placeholder.info == 'Good conditions' assert dev.placeholder.info == 'Good conditions'
assert dev.placeholder.pallet == '24A' assert dev.placeholder.pallet == '24A'
assert dev.placeholder.id_device_supplier == 'TTT' assert dev.placeholder.id_device_supplier == 'TTT'
@ -1781,7 +1751,7 @@ def test_add_placeholder_ods(user3: UserClientFlask):
assert Device.query.count() == 3 assert Device.query.count() == 3
dev = Device.query.first() dev = Device.query.first()
assert dev.hid == 'laptop-sony-vaio-12345678' assert dev.hid == 'laptop-sony-vaio-12345678'
assert dev.placeholder.phid == 'a123' assert dev.placeholder.phid == '1'
assert dev.placeholder.info == 'Good conditions' assert dev.placeholder.info == 'Good conditions'
assert dev.placeholder.pallet == '24A' assert dev.placeholder.pallet == '24A'
assert dev.placeholder.id_device_supplier == 'TTT' assert dev.placeholder.id_device_supplier == 'TTT'
@ -1809,10 +1779,11 @@ def test_add_placeholder_office_open_xml(user3: UserClientFlask):
assert Device.query.count() == 3 assert Device.query.count() == 3
dev = Device.query.first() dev = Device.query.first()
assert dev.hid == 'laptop-sony-vaio-12345678' assert dev.hid == 'laptop-sony-vaio-12345678'
assert dev.placeholder.phid == 'a123' assert dev.placeholder.phid == '1'
assert dev.placeholder.info == 'Good conditions' assert dev.placeholder.info == 'Good conditions'
assert dev.placeholder.pallet == '24A' assert dev.placeholder.pallet == '24A'
assert dev.placeholder.id_device_supplier == 'TTT' assert dev.placeholder.id_device_supplier == 'TTT'
assert dev.placeholder.id_device_internal == 'AA'
@pytest.mark.mvp @pytest.mark.mvp
@ -1921,8 +1892,8 @@ def test_placeholder_log_manual_edit(user3: UserClientFlask):
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Laptop", 'type': "Laptop",
'phid': 'ace',
'serial_number': "AAAAB", 'serial_number': "AAAAB",
'part_number': "AAAAB",
'model': "LC27T55", 'model': "LC27T55",
'manufacturer': "Samsung", 'manufacturer': "Samsung",
'generation': 1, 'generation': 1,
@ -1930,9 +1901,13 @@ def test_placeholder_log_manual_edit(user3: UserClientFlask):
'height': 0.1, 'height': 0.1,
'depth': 0.1, 'depth': 0.1,
'id_device_supplier': "b2", 'id_device_supplier': "b2",
'id_device_internal': "b2i",
} }
user3.post(uri, data=data) user3.post(uri, data=data)
dev = Device.query.one() dev = Device.query.one()
plz = Placeholder.query.first()
assert plz.id_device_supplier == "b2"
assert plz.id_device_internal == "b2i"
uri = '/inventory/device/edit/{}/'.format(dev.devicehub_id) uri = '/inventory/device/edit/{}/'.format(dev.devicehub_id)
user3.get(uri) user3.get(uri)
@ -1948,16 +1923,20 @@ def test_placeholder_log_manual_edit(user3: UserClientFlask):
'height': 0.1, 'height': 0.1,
'depth': 0.1, 'depth': 0.1,
'id_device_supplier': "a2", 'id_device_supplier': "a2",
'id_device_internal': "a2i",
} }
user3.post(uri, data=data) user3.post(uri, data=data)
plz = Placeholder.query.first()
assert plz.id_device_supplier == "a2"
assert plz.id_device_internal == "a2i"
uri = '/inventory/placeholder-logs/' uri = '/inventory/placeholder-logs/'
body, status = user3.get(uri) body, status = user3.get(uri)
assert status == '200 OK' assert status == '200 OK'
assert "Placeholder Logs" in body assert "Placeholder Logs" in body
assert "Web form" in body
assert "ace" in body
assert "Update" in body assert "Update" in body
assert "Web form" in body
assert "1" in body
assert dev.devicehub_id in body assert dev.devicehub_id in body
assert "" in body assert "" in body
assert "CSV" not in body assert "CSV" not in body
@ -1980,7 +1959,7 @@ def test_placeholder_log_excel_new(user3: UserClientFlask):
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
dev = Device.query.first() dev = Device.query.first()
assert dev.placeholder.phid == 'a123' assert dev.placeholder.phid == '1'
uri = '/inventory/placeholder-logs/' uri = '/inventory/placeholder-logs/'
body, status = user3.get(uri) body, status = user3.get(uri)
@ -1989,7 +1968,6 @@ def test_placeholder_log_excel_new(user3: UserClientFlask):
assert dev.placeholder.phid in body assert dev.placeholder.phid in body
assert dev.devicehub_id in body assert dev.devicehub_id in body
assert "Web form" not in body assert "Web form" not in body
assert "Update" not in body
assert "New device" in body assert "New device" in body
assert "" in body assert "" in body
assert "CSV" not in body assert "CSV" not in body
@ -2023,7 +2001,7 @@ def test_placeholder_log_excel_update(user3: UserClientFlask):
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
dev = Device.query.first() dev = Device.query.first()
assert dev.placeholder.phid == 'a123' assert dev.placeholder.phid == '1'
uri = '/inventory/placeholder-logs/' uri = '/inventory/placeholder-logs/'
body, status = user3.get(uri) body, status = user3.get(uri)
@ -2032,7 +2010,6 @@ def test_placeholder_log_excel_update(user3: UserClientFlask):
assert dev.placeholder.phid in body assert dev.placeholder.phid in body
assert dev.devicehub_id in body assert dev.devicehub_id in body
assert "Web form" not in body assert "Web form" not in body
assert "Update" in body
assert "New device" in body assert "New device" in body
assert "" in body assert "" in body
assert "CSV" in body assert "CSV" in body
@ -2070,7 +2047,7 @@ def test_add_placeholder_excel_from_lot(user3: UserClientFlask):
assert Device.query.count() == 3 assert Device.query.count() == 3
dev = Device.query.first() dev = Device.query.first()
assert dev.hid == 'laptop-sony-vaio-12345678' assert dev.hid == 'laptop-sony-vaio-12345678'
assert dev.placeholder.phid == 'a123' assert dev.placeholder.phid == '1'
assert dev.placeholder.info == 'Good conditions' assert dev.placeholder.info == 'Good conditions'
assert dev.placeholder.pallet == '24A' assert dev.placeholder.pallet == '24A'
assert dev.placeholder.id_device_supplier == 'TTT' assert dev.placeholder.id_device_supplier == 'TTT'
@ -2097,7 +2074,6 @@ def test_add_new_placeholder_from_lot(user3: UserClientFlask):
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Laptop", 'type': "Laptop",
'phid': 'ace',
'serial_number': "AAAAB", 'serial_number': "AAAAB",
'model': "LC27T55", 'model': "LC27T55",
'manufacturer': "Samsung", 'manufacturer': "Samsung",
@ -2110,7 +2086,7 @@ def test_add_new_placeholder_from_lot(user3: UserClientFlask):
user3.post(uri, data=data) user3.post(uri, data=data)
dev = Device.query.one() dev = Device.query.one()
assert dev.hid == 'laptop-samsung-lc27t55-aaaab' assert dev.hid == 'laptop-samsung-lc27t55-aaaab'
assert dev.placeholder.phid == 'ace' assert dev.placeholder.phid == '1'
assert len(lot.devices) == 1 assert len(lot.devices) == 1
@ -2124,7 +2100,6 @@ def test_manual_binding(user3: UserClientFlask):
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Laptop", 'type': "Laptop",
'phid': 'sid',
'serial_number': "AAAAB", 'serial_number': "AAAAB",
'model': "LC27T55", 'model': "LC27T55",
'manufacturer': "Samsung", 'manufacturer': "Samsung",
@ -2136,7 +2111,7 @@ def test_manual_binding(user3: UserClientFlask):
user3.post(uri, data=data) user3.post(uri, data=data)
dev = Device.query.one() dev = Device.query.one()
assert dev.hid == 'laptop-samsung-lc27t55-aaaab' assert dev.hid == 'laptop-samsung-lc27t55-aaaab'
assert dev.placeholder.phid == 'sid' assert dev.placeholder.phid == '1'
assert dev.placeholder.is_abstract is False assert dev.placeholder.is_abstract is False
# add device from wb # add device from wb
@ -2155,7 +2130,7 @@ def test_manual_binding(user3: UserClientFlask):
# page binding # page binding
dhid = dev_wb.dhid dhid = dev_wb.dhid
uri = f'/inventory/binding/{dhid}/sid/' uri = f'/inventory/binding/{dhid}/1/'
body, status = user3.get(uri) body, status = user3.get(uri)
assert status == '200 OK' assert status == '200 OK'
assert 'sid' in body assert 'sid' in body
@ -2174,7 +2149,7 @@ def test_manual_binding(user3: UserClientFlask):
assert txt in body assert txt in body
# check new structure # check new structure
assert dev_wb.binding.phid == 'sid' assert dev_wb.binding.phid == '1'
assert dev_wb.binding.device == dev assert dev_wb.binding.device == dev
assert Placeholder.query.filter_by(id=old_placeholder.id).first() is None assert Placeholder.query.filter_by(id=old_placeholder.id).first() is None
assert Device.query.filter_by(id=old_placeholder.device.id).first() is None assert Device.query.filter_by(id=old_placeholder.device.id).first() is None
@ -2237,7 +2212,6 @@ def test_unbinding(user3: UserClientFlask):
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Laptop", 'type': "Laptop",
'phid': 'sid',
'serial_number': "AAAAB", 'serial_number': "AAAAB",
'model': "LC27T55", 'model': "LC27T55",
'manufacturer': "Samsung", 'manufacturer': "Samsung",
@ -2262,7 +2236,7 @@ def test_unbinding(user3: UserClientFlask):
# page binding # page binding
dhid = dev_wb.dhid dhid = dev_wb.dhid
uri = f'/inventory/binding/{dhid}/sid/' uri = f'/inventory/binding/{dhid}/1/'
user3.get(uri) user3.get(uri)
# action binding # action binding
@ -2272,10 +2246,10 @@ def test_unbinding(user3: UserClientFlask):
dhid = dev.dhid dhid = dev.dhid
# action unbinding # action unbinding
uri = '/inventory/unbinding/sid/' uri = '/inventory/unbinding/1/'
body, status = user3.post(uri, data={}) body, status = user3.post(uri, data={})
assert status == '200 OK' assert status == '200 OK'
txt = f'Device with PHID:"sid" and DHID: {dhid} unbind successfully!' txt = f'Device with PHID:"1" and DHID: {dhid} unbind successfully!'
assert txt in body assert txt in body
# assert 'Device "sid" unbind successfully!' in body # assert 'Device "sid" unbind successfully!' in body
@ -2400,8 +2374,8 @@ def test_bug_3821_binding(user3: UserClientFlask):
user3.post(uri, data=data) user3.post(uri, data=data)
dev = Device.query.one() dev = Device.query.one()
dhid = dev.dhid dhid = dev.dhid
assert dev.phid() == 'sid' assert dev.phid() == '1'
uri = f'/inventory/binding/{dhid}/sid/' uri = f'/inventory/binding/{dhid}/1/'
body, status = user3.get(uri) body, status = user3.get(uri)
assert status == '200 OK' assert status == '200 OK'
assert 'is not a Snapshot device!' in body assert 'is not a Snapshot device!' in body