fix tests

This commit is contained in:
Cayo Puigdefabregas 2022-07-19 12:27:10 +02:00
parent d7b9d01165
commit aed23450df
6 changed files with 438 additions and 259 deletions

File diff suppressed because one or more lines are too long

View File

@ -190,7 +190,7 @@ def test_inventory_with_device(user3: UserClientFlask):
assert status == '200 OK' assert status == '200 OK'
assert "Unassigned" in body assert "Unassigned" in body
assert db_snapthot.device.devicehub_id in body assert db_snapthot.device.binding.device.devicehub_id in body
@pytest.mark.mvp @pytest.mark.mvp
@ -203,7 +203,7 @@ def test_inventory_filter(user3: UserClientFlask):
assert status == '200 OK' assert status == '200 OK'
assert "Unassigned" in body assert "Unassigned" in body
assert db_snapthot.device.devicehub_id in body assert db_snapthot.device.binding.device.devicehub_id in body
@pytest.mark.mvp @pytest.mark.mvp
@ -709,7 +709,7 @@ def test_action_recycling(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
} }
uri = '/inventory/action/add/' uri = '/inventory/action/add/'
@ -722,15 +722,15 @@ def test_action_recycling(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Recycling", 'type': "Recycling",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
} }
uri = '/inventory/action/add/' uri = '/inventory/action/add/'
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert status == '200 OK' assert status == '200 OK'
assert dev.actions[-1].type == 'Recycling' assert dev.binding.device.actions[-1].type == 'Recycling'
assert 'Action "Recycling" created successfully!' in body assert 'Action "Recycling" created successfully!' in body
assert dev.devicehub_id in body assert dev.binding.device.devicehub_id in body
@pytest.mark.mvp @pytest.mark.mvp
@ -764,15 +764,15 @@ def test_action_use(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Use", 'type': "Use",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
} }
uri = '/inventory/action/add/' uri = '/inventory/action/add/'
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert status == '200 OK' assert status == '200 OK'
assert dev.actions[-1].type == 'Use' assert dev.binding.device.actions[-1].type == 'Use'
assert 'Action "Use" created successfully!' in body assert 'Action "Use" created successfully!' in body
assert dev.devicehub_id in body assert dev.binding.device.devicehub_id in body
@pytest.mark.mvp @pytest.mark.mvp
@ -787,15 +787,15 @@ def test_action_refurbish(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Refurbish", 'type': "Refurbish",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
} }
uri = '/inventory/action/add/' uri = '/inventory/action/add/'
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert status == '200 OK' assert status == '200 OK'
assert dev.actions[-1].type == 'Refurbish' assert dev.binding.device.actions[-1].type == 'Refurbish'
assert 'Action "Refurbish" created successfully!' in body assert 'Action "Refurbish" created successfully!' in body
assert dev.devicehub_id in body assert dev.binding.device.devicehub_id in body
@pytest.mark.mvp @pytest.mark.mvp
@ -810,15 +810,15 @@ def test_action_management(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Management", 'type': "Management",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
} }
uri = '/inventory/action/add/' uri = '/inventory/action/add/'
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert status == '200 OK' assert status == '200 OK'
assert dev.actions[-1].type == 'Management' assert dev.binding.device.actions[-1].type == 'Management'
assert 'Action "Management" created successfully!' in body assert 'Action "Management" created successfully!' in body
assert dev.devicehub_id in body assert dev.binding.device.devicehub_id in body
@pytest.mark.mvp @pytest.mark.mvp
@ -833,7 +833,7 @@ def test_action_allocate(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-01-01', 'start_time': '2000-01-01',
'end_time': '2000-06-01', 'end_time': '2000-06-01',
'end_users': 2, 'end_users': 2,
@ -842,9 +842,9 @@ def test_action_allocate(user3: UserClientFlask):
uri = '/inventory/action/allocate/add/' uri = '/inventory/action/allocate/add/'
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert status == '200 OK' assert status == '200 OK'
assert dev.actions[-1].type == 'Allocate' assert dev.binding.device.actions[-1].type == 'Allocate'
assert 'Action "Allocate" created successfully!' in body assert 'Action "Allocate" created successfully!' in body
assert dev.devicehub_id in body assert dev.binding.device.devicehub_id in body
@pytest.mark.mvp @pytest.mark.mvp
@ -859,18 +859,18 @@ def test_action_allocate_error_required(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Trade", 'type': "Trade",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
} }
uri = '/inventory/action/allocate/add/' uri = '/inventory/action/allocate/add/'
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert dev.actions[-1].type != 'Allocate' assert 'Allocate' not in [x.type for x in dev.binding.device.actions]
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
} }
uri = '/inventory/action/allocate/add/' uri = '/inventory/action/allocate/add/'
@ -892,7 +892,7 @@ def test_action_allocate_error_dates(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-06-01', 'start_time': '2000-06-01',
'end_time': '2000-01-01', 'end_time': '2000-01-01',
'end_users': 2, 'end_users': 2,
@ -903,7 +903,7 @@ def test_action_allocate_error_dates(user3: UserClientFlask):
assert status == '200 OK' assert status == '200 OK'
assert 'Action Allocate error' in body assert 'Action Allocate error' in body
assert 'The action cannot finish before it starts.' in body assert 'The action cannot finish before it starts.' in body
assert dev.actions[-1].type != 'Allocate' assert 'Allocate' not in [x.type for x in dev.binding.device.actions]
@pytest.mark.mvp @pytest.mark.mvp
@ -920,7 +920,7 @@ def test_action_allocate_error_future_dates(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': start_time, 'start_time': start_time,
'end_time': end_time, 'end_time': end_time,
'end_users': 2, 'end_users': 2,
@ -931,7 +931,7 @@ def test_action_allocate_error_future_dates(user3: UserClientFlask):
assert status == '200 OK' assert status == '200 OK'
assert 'Action Allocate error' in body assert 'Action Allocate error' in body
assert 'Not a valid date value.!' in body assert 'Not a valid date value.!' in body
assert dev.actions[-1].type != 'Allocate' assert 'Allocate' not in [x.type for x in dev.binding.device.actions]
@pytest.mark.mvp @pytest.mark.mvp
@ -946,7 +946,7 @@ def test_action_deallocate(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-01-01', 'start_time': '2000-01-01',
'end_time': '2000-06-01', 'end_time': '2000-06-01',
'end_users': 2, 'end_users': 2,
@ -955,22 +955,22 @@ def test_action_deallocate(user3: UserClientFlask):
uri = '/inventory/action/allocate/add/' uri = '/inventory/action/allocate/add/'
user3.post(uri, data=data) user3.post(uri, data=data)
assert dev.allocated_status.type == 'Allocate' assert dev.binding.device.allocated_status.type == 'Allocate'
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Deallocate", 'type': "Deallocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-01-01', 'start_time': '2000-01-01',
'end_time': '2000-06-01', 'end_time': '2000-06-01',
'end_users': 2, 'end_users': 2,
} }
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert status == '200 OK' assert status == '200 OK'
assert dev.allocated_status.type == 'Deallocate' assert dev.binding.device.allocated_status.type == 'Deallocate'
assert 'Action "Deallocate" created successfully!' in body assert 'Action "Deallocate" created successfully!' in body
assert dev.devicehub_id in body assert dev.binding.device.devicehub_id in body
@pytest.mark.mvp @pytest.mark.mvp
@ -985,7 +985,7 @@ def test_action_deallocate_error(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-05-01', 'start_time': '2000-05-01',
'end_time': '2000-06-01', 'end_time': '2000-06-01',
'end_users': 2, 'end_users': 2,
@ -994,20 +994,20 @@ def test_action_deallocate_error(user3: UserClientFlask):
uri = '/inventory/action/allocate/add/' uri = '/inventory/action/allocate/add/'
user3.post(uri, data=data) user3.post(uri, data=data)
assert dev.allocated_status.type == 'Allocate' assert dev.binding.device.allocated_status.type == 'Allocate'
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Deallocate", 'type': "Deallocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-01-01', 'start_time': '2000-01-01',
'end_time': '2000-02-01', 'end_time': '2000-02-01',
'end_users': 2, 'end_users': 2,
} }
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert status == '200 OK' assert status == '200 OK'
assert dev.allocated_status.type != 'Deallocate' assert dev.binding.device.allocated_status.type != 'Deallocate'
assert 'Action Deallocate error!' in body assert 'Action Deallocate error!' in body
assert 'Sorry some of this devices are actually deallocate' in body assert 'Sorry some of this devices are actually deallocate' in body
@ -1024,7 +1024,7 @@ def test_action_allocate_deallocate_error(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-01-01', 'start_time': '2000-01-01',
'end_time': '2000-01-01', 'end_time': '2000-01-01',
'end_users': 2, 'end_users': 2,
@ -1033,36 +1033,36 @@ def test_action_allocate_deallocate_error(user3: UserClientFlask):
uri = '/inventory/action/allocate/add/' uri = '/inventory/action/allocate/add/'
user3.post(uri, data=data) user3.post(uri, data=data)
assert dev.allocated_status.type == 'Allocate' assert dev.binding.device.allocated_status.type == 'Allocate'
assert len(dev.actions) == 11 assert len(dev.binding.device.actions) == 1
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Deallocate", 'type': "Deallocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-02-01', 'start_time': '2000-02-01',
'end_time': '2000-02-01', 'end_time': '2000-02-01',
'end_users': 2, 'end_users': 2,
} }
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert status == '200 OK' assert status == '200 OK'
assert dev.allocated_status.type == 'Deallocate' assert dev.binding.device.allocated_status.type == 'Deallocate'
assert len(dev.actions) == 12 assert len(dev.binding.device.actions) == 2
# is not possible to do an allocate between an allocate and an deallocate # is not possible to do an allocate between an allocate and an deallocate
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-01-15', 'start_time': '2000-01-15',
'end_time': '2000-01-15', 'end_time': '2000-01-15',
'end_users': 2, 'end_users': 2,
} }
user3.post(uri, data=data) user3.post(uri, data=data)
assert dev.allocated_status.type == 'Deallocate' assert dev.binding.device.allocated_status.type == 'Deallocate'
# assert 'Action Deallocate error!' in body # assert 'Action Deallocate error!' in body
# assert 'Sorry some of this devices are actually deallocate' in body # assert 'Sorry some of this devices are actually deallocate' in body
# #
@ -1070,14 +1070,14 @@ def test_action_allocate_deallocate_error(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Deallocate", 'type': "Deallocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-01-15', 'start_time': '2000-01-15',
'end_time': '2000-01-15', 'end_time': '2000-01-15',
'end_users': 2, 'end_users': 2,
} }
user3.post(uri, data=data) user3.post(uri, data=data)
assert len(dev.actions) == 12 assert len(dev.binding.device.actions) == 2
@pytest.mark.mvp @pytest.mark.mvp
@ -1092,7 +1092,7 @@ def test_action_allocate_deallocate_error2(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-01-10', 'start_time': '2000-01-10',
'end_users': 2, 'end_users': 2,
} }
@ -1100,25 +1100,25 @@ def test_action_allocate_deallocate_error2(user3: UserClientFlask):
uri = '/inventory/action/allocate/add/' uri = '/inventory/action/allocate/add/'
user3.post(uri, data=data) user3.post(uri, data=data)
assert len(dev.actions) == 11 assert len(dev.binding.device.actions) == 1
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Deallocate", 'type': "Deallocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-01-20', 'start_time': '2000-01-20',
'end_users': 2, 'end_users': 2,
} }
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert status == '200 OK' assert status == '200 OK'
assert len(dev.actions) == 12 assert len(dev.binding.device.actions) == 2
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-02-10', 'start_time': '2000-02-10',
'end_users': 2, 'end_users': 2,
} }
@ -1126,40 +1126,40 @@ def test_action_allocate_deallocate_error2(user3: UserClientFlask):
uri = '/inventory/action/allocate/add/' uri = '/inventory/action/allocate/add/'
user3.post(uri, data=data) user3.post(uri, data=data)
assert len(dev.actions) == 13 assert len(dev.binding.device.actions) == 3
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Deallocate", 'type': "Deallocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-02-20', 'start_time': '2000-02-20',
'end_users': 2, 'end_users': 2,
} }
user3.post(uri, data=data) user3.post(uri, data=data)
assert len(dev.actions) == 14 assert len(dev.binding.device.actions) == 4
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Allocate", 'type': "Allocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-01-25', 'start_time': '2000-01-25',
'end_users': 2, 'end_users': 2,
} }
user3.post(uri, data=data) user3.post(uri, data=data)
assert len(dev.actions) == 15 assert len(dev.binding.device.actions) == 5
data = { data = {
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "Deallocate", 'type': "Deallocate",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
'start_time': '2000-01-27', 'start_time': '2000-01-27',
'end_users': 2, 'end_users': 2,
} }
user3.post(uri, data=data) user3.post(uri, data=data)
assert len(dev.actions) == 16 assert len(dev.binding.device.actions) == 6
@pytest.mark.mvp @pytest.mark.mvp
@ -1174,20 +1174,21 @@ def test_action_toprepare(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
'type': "ToPrepare", 'type': "ToPrepare",
'severity': "Info", 'severity': "Info",
'devices': "{}".format(dev.id), 'devices': "{}".format(dev.binding.device.id),
} }
uri = '/inventory/action/add/' uri = '/inventory/action/add/'
body, status = user3.post(uri, data=data) body, status = user3.post(uri, data=data)
assert status == '200 OK' assert status == '200 OK'
assert dev.actions[-1].type == 'ToPrepare' assert dev.binding.device.actions[-1].type == 'ToPrepare'
assert 'Action "ToPrepare" created successfully!' in body assert 'Action "ToPrepare" created successfully!' in body
assert dev.devicehub_id in body assert dev.binding.device.devicehub_id in body
@pytest.mark.mvp @pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__) @pytest.mark.usefixtures(conftest.app_context.__name__)
def test_action_prepare(user3: UserClientFlask): def test_action_prepare(user3: UserClientFlask):
# ???
snap = create_device(user3, 'real-eee-1001pxd.snapshot.12.json') snap = create_device(user3, 'real-eee-1001pxd.snapshot.12.json')
dev = snap.device dev = snap.device
uri = '/inventory/device/' uri = '/inventory/device/'

View File

@ -367,18 +367,6 @@ def test_snapshot_mismatch_id():
pass pass
@pytest.mark.mvp
def test_snapshot_tag_inner_tag(user: UserClient, tag_id: str, app: Devicehub):
"""Tests a posting Snapshot with a local tag."""
b = yaml2json('basic.snapshot')
b['device']['tags'] = [{'type': 'Tag', 'id': tag_id}]
snapshot_and_check(user, b, action_types=(BenchmarkProcessor.t, VisualTest.t))
with app.app_context():
tag = Tag.query.all()[0] # type: Tag
assert tag.device_id == 3, 'Tag should be linked to the first device'
@pytest.mark.mvp @pytest.mark.mvp
def test_snapshot_tag_inner_tag_mismatch_between_tags_and_hid( def test_snapshot_tag_inner_tag_mismatch_between_tags_and_hid(
user: UserClient, tag_id: str user: UserClient, tag_id: str

View File

@ -92,7 +92,7 @@ def test_wb11_to_wb11_with_uuid_api(user: UserClient):
db_snapthot = Snapshot.query.one() db_snapthot = Snapshot.query.one()
device = db_snapthot.device device = db_snapthot.device
assert Computer.query.count() == 1 assert Computer.query.count() == 2
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
assert device.system_uuid is None assert device.system_uuid is None
@ -106,10 +106,14 @@ def test_wb11_to_wb11_with_uuid_api(user: UserClient):
snapshot_11['debug']['lshw']['configuration']['uuid'] snapshot_11['debug']['lshw']['configuration']['uuid']
== '364ee69c-9c82-9cb1-2111-88ae1da6f3d0' == '364ee69c-9c82-9cb1-2111-88ae1da6f3d0'
) )
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
@pytest.mark.mvp @pytest.mark.mvp
@ -123,20 +127,28 @@ def test_wb11_with_uuid_to_wb11_api(user: UserClient):
snapshot_11['uuid'] = '0973fda0-589a-11eb-ae93-0242ac130003' snapshot_11['uuid'] = '0973fda0-589a-11eb-ae93-0242ac130003'
user.post(snapshot_11, res=Snapshot) user.post(snapshot_11, res=Snapshot)
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
# insert the same computer with wb11 with hid and with uuid, (new version) # insert the same computer with wb11 with hid and with uuid, (new version)
snapshot_11 = conftest.file_json('system_uuid3.json') snapshot_11 = conftest.file_json('system_uuid3.json')
assert 'debug' not in snapshot_11 assert 'debug' not in snapshot_11
user.post(snapshot_11, res=Snapshot) user.post(snapshot_11, res=Snapshot)
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
@pytest.mark.mvp @pytest.mark.mvp
@ -150,10 +162,14 @@ def test_wb11_with_uuid_to_wb11_without_hid_api(user: UserClient):
snapshot_11['uuid'] = '0973fda0-589a-11eb-ae93-0242ac130003' snapshot_11['uuid'] = '0973fda0-589a-11eb-ae93-0242ac130003'
user.post(snapshot_11, res=Snapshot) user.post(snapshot_11, res=Snapshot)
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
# insert the same computer with wb11 with hid and with uuid, (new version) # insert the same computer with wb11 with hid and with uuid, (new version)
snapshot_11 = conftest.file_json('system_uuid3.json') snapshot_11 = conftest.file_json('system_uuid3.json')
@ -162,7 +178,7 @@ def test_wb11_with_uuid_to_wb11_without_hid_api(user: UserClient):
snapshot_11['debug'] = {'lshw': snapshot_lite['data']['lshw']} snapshot_11['debug'] = {'lshw': snapshot_lite['data']['lshw']}
user.post(snapshot_11, res=Snapshot) user.post(snapshot_11, res=Snapshot)
assert Computer.query.count() == 1 assert Computer.query.count() == 2
@pytest.mark.mvp @pytest.mark.mvp
@ -186,7 +202,7 @@ def test_wb11_to_wb11_with_uuid_form(user3: UserClientFlask):
db_snapthot = Snapshot.query.one() db_snapthot = Snapshot.query.one()
device = db_snapthot.device device = db_snapthot.device
assert Computer.query.count() == 1 assert Computer.query.count() == 2
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
assert device.system_uuid is None assert device.system_uuid is None
@ -203,10 +219,14 @@ def test_wb11_to_wb11_with_uuid_form(user3: UserClientFlask):
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
@pytest.mark.mvp @pytest.mark.mvp
@ -231,10 +251,14 @@ def test_wb11_with_uuid_to_wb11_form(user3: UserClientFlask):
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
# insert the same computer with wb11 with hid and with uuid, (new version) # insert the same computer with wb11 with hid and with uuid, (new version)
snapshot = conftest.file_json('system_uuid3.json') snapshot = conftest.file_json('system_uuid3.json')
@ -248,10 +272,14 @@ def test_wb11_with_uuid_to_wb11_form(user3: UserClientFlask):
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
@pytest.mark.mvp @pytest.mark.mvp
@ -276,10 +304,14 @@ def test_wb11_with_uuid_to_wb11_without_hid_form(user3: UserClientFlask):
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
# insert the same computer with wb11 with hid and with uuid, (new version) # insert the same computer with wb11 with hid and with uuid, (new version)
snapshot_11 = conftest.file_json('system_uuid3.json') snapshot_11 = conftest.file_json('system_uuid3.json')
@ -295,7 +327,7 @@ def test_wb11_with_uuid_to_wb11_without_hid_form(user3: UserClientFlask):
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
@pytest.mark.mvp @pytest.mark.mvp
@ -305,17 +337,25 @@ def test_wb11_to_wblite_api(user: UserClient):
# insert computer with wb11 with hid and without uuid, (old version) # insert computer with wb11 with hid and without uuid, (old version)
snapshot_11 = conftest.file_json('system_uuid3.json') snapshot_11 = conftest.file_json('system_uuid3.json')
user.post(snapshot_11, res=Snapshot) user.post(snapshot_11, res=Snapshot)
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert device.system_uuid is None assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert device.system_uuid is None
snapshot_lite = conftest.file_json('system_uuid2.json') snapshot_lite = conftest.file_json('system_uuid2.json')
user.post(snapshot_lite, uri="/api/inventory/") user.post(snapshot_lite, uri="/api/inventory/")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
@pytest.mark.mvp @pytest.mark.mvp
@ -324,17 +364,25 @@ def test_wblite_to_wb11_api(user: UserClient):
snapshot_lite = conftest.file_json('system_uuid2.json') snapshot_lite = conftest.file_json('system_uuid2.json')
user.post(snapshot_lite, uri="/api/inventory/") user.post(snapshot_lite, uri="/api/inventory/")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
snapshot_11 = conftest.file_json('system_uuid3.json') snapshot_11 = conftest.file_json('system_uuid3.json')
user.post(snapshot_11, res=Snapshot) user.post(snapshot_11, res=Snapshot)
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
@pytest.mark.mvp @pytest.mark.mvp
@ -354,10 +402,14 @@ def test_wb11_to_wblite_form(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert device.system_uuid is None assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert device.system_uuid is None
file_name = 'system_uuid2.json' file_name = 'system_uuid2.json'
snapshot_lite = conftest.file_json(file_name) snapshot_lite = conftest.file_json(file_name)
@ -369,10 +421,14 @@ def test_wb11_to_wblite_form(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
@pytest.mark.mvp @pytest.mark.mvp
@ -392,10 +448,14 @@ def test_wblite_to_wb11_form(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
file_name = 'system_uuid3.json' file_name = 'system_uuid3.json'
snapshot_11 = conftest.file_json(file_name) snapshot_11 = conftest.file_json(file_name)
@ -407,10 +467,14 @@ def test_wblite_to_wb11_form(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
@pytest.mark.mvp @pytest.mark.mvp
@ -419,18 +483,26 @@ def test_wblite_to_wblite_api(user: UserClient):
snapshot_lite = conftest.file_json('system_uuid2.json') snapshot_lite = conftest.file_json('system_uuid2.json')
user.post(snapshot_lite, uri="/api/inventory/") user.post(snapshot_lite, uri="/api/inventory/")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
snapshot_lite = conftest.file_json('system_uuid2.json') snapshot_lite = conftest.file_json('system_uuid2.json')
snapshot_lite['uuid'] = '0973fda0-589a-11eb-ae93-0242ac130003' snapshot_lite['uuid'] = '0973fda0-589a-11eb-ae93-0242ac130003'
user.post(snapshot_lite, uri="/api/inventory/") user.post(snapshot_lite, uri="/api/inventory/")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
@pytest.mark.mvp @pytest.mark.mvp
@ -450,10 +522,14 @@ def test_wblite_to_wblite_form(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
file_name = 'system_uuid2.json' file_name = 'system_uuid2.json'
snapshot_lite = conftest.file_json(file_name) snapshot_lite = conftest.file_json(file_name)
@ -466,10 +542,14 @@ def test_wblite_to_wblite_form(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
@pytest.mark.mvp @pytest.mark.mvp
@ -479,17 +559,21 @@ def test_wb11_to_wb11_duplicity_api(user: UserClient):
# insert computer with wb11 with hid and without uuid, (old version) # insert computer with wb11 with hid and without uuid, (old version)
snapshot_11 = conftest.file_json('system_uuid3.json') snapshot_11 = conftest.file_json('system_uuid3.json')
user.post(snapshot_11, res=Snapshot) user.post(snapshot_11, res=Snapshot)
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert device.system_uuid is None assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert device.system_uuid is None
snapshot_11 = conftest.file_json('system_uuid3.json') snapshot_11 = conftest.file_json('system_uuid3.json')
snapshot_11['uuid'] = '0973fda0-589a-11eb-ae93-0242ac130003' snapshot_11['uuid'] = '0973fda0-589a-11eb-ae93-0242ac130003'
components = [x for x in snapshot_11['components'] if x['type'] != 'NetworkAdapter'] components = [x for x in snapshot_11['components'] if x['type'] != 'NetworkAdapter']
snapshot_11['components'] = components snapshot_11['components'] = components
user.post(snapshot_11, res=Snapshot) user.post(snapshot_11, res=Snapshot)
assert Computer.query.count() == 2 assert Computer.query.count() == 4
for c in Computer.query.all(): for c in Computer.query.all():
assert 'laptop-acer-aohappy-lusea0d010038879a01601' in c.hid assert 'laptop-acer-aohappy-lusea0d010038879a01601' in c.hid
assert c.system_uuid is None assert c.system_uuid is None
@ -512,10 +596,14 @@ def test_wb11_to_wb11_duplicity_form(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert device.system_uuid is None assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert device.system_uuid is None
snapshot_11 = conftest.file_json('system_uuid3.json') snapshot_11 = conftest.file_json('system_uuid3.json')
snapshot_11['uuid'] = '0973fda0-589a-11eb-ae93-0242ac130003' snapshot_11['uuid'] = '0973fda0-589a-11eb-ae93-0242ac130003'
@ -530,10 +618,12 @@ def test_wb11_to_wb11_duplicity_form(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 2
for c in Computer.query.all(): assert Computer.query.count() == 4
assert 'laptop-acer-aohappy-lusea0d010038879a01601' in c.hid for device in Computer.query.all():
assert c.system_uuid is None if device.binding:
assert 'laptop-acer-aohappy-lusea0d010038879a01601' in device.hid
assert device.system_uuid is None
@pytest.mark.mvp @pytest.mark.mvp
@ -543,10 +633,14 @@ def test_wb11_smbios_2_5_api(user: UserClient):
# insert computer with wb11 with hid and without uuid, (old version) # insert computer with wb11 with hid and without uuid, (old version)
snapshot_11 = conftest.file_json('system_uuid4.json') snapshot_11 = conftest.file_json('system_uuid4.json')
user.post(snapshot_11, res=Snapshot) user.post(snapshot_11, res=Snapshot)
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert device.system_uuid is None assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert device.system_uuid is None
@pytest.mark.mvp @pytest.mark.mvp
@ -566,10 +660,14 @@ def test_wb11_smbios_2_5_form(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert device.system_uuid is None assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert device.system_uuid is None
@pytest.mark.mvp @pytest.mark.mvp
@ -580,10 +678,14 @@ def test_wblite_smbios_2_5_api(user: UserClient):
snapshot_lite = conftest.file_json('system_uuid2.json') snapshot_lite = conftest.file_json('system_uuid2.json')
snapshot_lite['data']['lshw']['capabilities']['smbios-3.0'] = 'SMBIOS version 2.5' snapshot_lite['data']['lshw']['capabilities']['smbios-3.0'] = 'SMBIOS version 2.5'
user.post(snapshot_lite, uri="/api/inventory/") user.post(snapshot_lite, uri="/api/inventory/")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'
@pytest.mark.mvp @pytest.mark.mvp
@ -604,7 +706,11 @@ def test_wblite_smbios_2_5_form(user3: UserClientFlask):
'csrf_token': generate_csrf(), 'csrf_token': generate_csrf(),
} }
user3.post(uri, data=data, content_type="multipart/form-data") user3.post(uri, data=data, content_type="multipart/form-data")
assert Computer.query.count() == 1 assert Computer.query.count() == 2
device = Computer.query.one() for device in Computer.query.all():
assert device.hid == 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0' if device.binding:
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0' assert (
device.hid
== 'laptop-acer-aohappy-lusea0d010038879a01601-88:ae:1d:a6:f3:d0'
)
assert str(device.system_uuid) == '9ce64e36-829c-b19c-2111-88ae1da6f3d0'

View File

@ -2,26 +2,29 @@ import pathlib
import pytest import pytest
import requests_mock import requests_mock
from flask import g
from boltons.urlutils import URL from boltons.urlutils import URL
from ereuse_utils.session import DevicehubClient from ereuse_utils.session import DevicehubClient
from flask import g
from pytest import raises from pytest import raises
from teal.db import MultipleResourcesFound, ResourceNotFound, UniqueViolation, DBError from teal.db import DBError, MultipleResourcesFound, ResourceNotFound, UniqueViolation
from teal.marshmallow import ValidationError from teal.marshmallow import ValidationError
from ereuse_devicehub.client import UserClient, Client from ereuse_devicehub.client import Client, UserClient
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
from ereuse_devicehub.devicehub import Devicehub from ereuse_devicehub.devicehub import Devicehub
from ereuse_devicehub.resources.user.models import User
from ereuse_devicehub.resources.action.models import Snapshot from ereuse_devicehub.resources.action.models import Snapshot
from ereuse_devicehub.resources.agent.models import Organization from ereuse_devicehub.resources.agent.models import Organization
from ereuse_devicehub.resources.device.models import Desktop, Device from ereuse_devicehub.resources.device.models import Desktop, Device
from ereuse_devicehub.resources.enums import ComputerChassis from ereuse_devicehub.resources.enums import ComputerChassis
from ereuse_devicehub.resources.tag import Tag from ereuse_devicehub.resources.tag import Tag
from ereuse_devicehub.resources.tag.view import CannotCreateETag, LinkedToAnotherDevice, \ from ereuse_devicehub.resources.tag.view import (
TagNotLinked CannotCreateETag,
LinkedToAnotherDevice,
TagNotLinked,
)
from ereuse_devicehub.resources.user.models import User
from tests import conftest from tests import conftest
from tests.conftest import yaml2json, json_encode from tests.conftest import json_encode, yaml2json
@pytest.mark.mvp @pytest.mark.mvp
@ -29,7 +32,9 @@ from tests.conftest import yaml2json, json_encode
def test_create_tag(user: UserClient): def test_create_tag(user: UserClient):
"""Creates a tag specifying a custom organization.""" """Creates a tag specifying a custom organization."""
org = Organization(name='bar', tax_id='bartax') org = Organization(name='bar', tax_id='bartax')
tag = Tag(id='bar-1', org=org, provider=URL('http://foo.bar'), owner_id=user.user['id']) tag = Tag(
id='bar-1', org=org, provider=URL('http://foo.bar'), owner_id=user.user['id']
)
db.session.add(tag) db.session.add(tag)
db.session.commit() db.session.commit()
tag = Tag.query.one() tag = Tag.query.one()
@ -44,7 +49,9 @@ def test_create_tag(user: UserClient):
def test_create_tag_with_device(user: UserClient): def test_create_tag_with_device(user: UserClient):
"""Creates a tag specifying linked with one device.""" """Creates a tag specifying linked with one device."""
g.user = User.query.one() g.user = User.query.one()
pc = Desktop(serial_number='sn1', chassis=ComputerChassis.Tower, owner_id=user.user['id']) pc = Desktop(
serial_number='sn1', chassis=ComputerChassis.Tower, owner_id=user.user['id']
)
db.session.add(pc) db.session.add(pc)
db.session.commit() db.session.commit()
tag = Tag(id='bar', owner_id=user.user['id']) tag = Tag(id='bar', owner_id=user.user['id'])
@ -64,7 +71,9 @@ def test_delete_tags(user: UserClient, client: Client):
"""Delete a named tag.""" """Delete a named tag."""
# Delete Tag Named # Delete Tag Named
g.user = User.query.one() g.user = User.query.one()
pc = Desktop(serial_number='sn1', chassis=ComputerChassis.Tower, owner_id=user.user['id']) pc = Desktop(
serial_number='sn1', chassis=ComputerChassis.Tower, owner_id=user.user['id']
)
db.session.add(pc) db.session.add(pc)
db.session.commit() db.session.commit()
tag = Tag(id='bar', owner_id=user.user['id'], device_id=pc.id) tag = Tag(id='bar', owner_id=user.user['id'], device_id=pc.id)
@ -89,7 +98,9 @@ def test_delete_tags(user: UserClient, client: Client):
# Delete Tag UnNamed # Delete Tag UnNamed
org = Organization(name='bar', tax_id='bartax') org = Organization(name='bar', tax_id='bartax')
tag = Tag(id='bar-1', org=org, provider=URL('http://foo.bar'), owner_id=user.user['id']) tag = Tag(
id='bar-1', org=org, provider=URL('http://foo.bar'), owner_id=user.user['id']
)
db.session.add(tag) db.session.add(tag)
db.session.commit() db.session.commit()
tag = Tag.query.all()[-1] tag = Tag.query.all()[-1]
@ -106,7 +117,9 @@ def test_delete_tags(user: UserClient, client: Client):
def test_create_tag_default_org(user: UserClient): def test_create_tag_default_org(user: UserClient):
"""Creates a tag using the default organization.""" """Creates a tag using the default organization."""
tag = Tag(id='foo-1', owner_id=user.user['id']) tag = Tag(id='foo-1', owner_id=user.user['id'])
assert not tag.org_id, 'org-id is set as default value so it should only load on flush' assert (
not tag.org_id
), 'org-id is set as default value so it should only load on flush'
# We don't want the organization to load, or it would make this # We don't want the organization to load, or it would make this
# object, from transient to new (added to session) # object, from transient to new (added to session)
assert 'org' not in vars(tag), 'Organization should not have been loaded' assert 'org' not in vars(tag), 'Organization should not have been loaded'
@ -188,7 +201,9 @@ def test_tag_get_device_from_tag_endpoint(app: Devicehub, user: UserClient):
# Create a pc with a tag # Create a pc with a tag
g.user = User.query.one() g.user = User.query.one()
tag = Tag(id='foo-bar', owner_id=user.user['id']) tag = Tag(id='foo-bar', owner_id=user.user['id'])
pc = Desktop(serial_number='sn1', chassis=ComputerChassis.Tower, owner_id=user.user['id']) pc = Desktop(
serial_number='sn1', chassis=ComputerChassis.Tower, owner_id=user.user['id']
)
pc.tags.add(tag) pc.tags.add(tag)
db.session.add(pc) db.session.add(pc)
db.session.commit() db.session.commit()
@ -213,7 +228,9 @@ def test_tag_get_device_from_tag_endpoint_no_tag(user: UserClient):
@pytest.mark.mvp @pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__) @pytest.mark.usefixtures(conftest.app_context.__name__)
def test_tag_get_device_from_tag_endpoint_multiple_tags(app: Devicehub, user: UserClient, user2: UserClient, client: Client): def test_tag_get_device_from_tag_endpoint_multiple_tags(
app: Devicehub, user: UserClient, user2: UserClient, client: Client
):
"""As above, but when there are two tags with the secondary ID, the """As above, but when there are two tags with the secondary ID, the
system should not return any of both (to be deterministic) so system should not return any of both (to be deterministic) so
it should raise an exception. it should raise an exception.
@ -232,8 +249,12 @@ def test_tag_get_device_from_tag_endpoint_multiple_tags(app: Devicehub, user: Us
tag1 = Tag.from_an_id('foo').filter_by(owner_id=user.user['id']).one() tag1 = Tag.from_an_id('foo').filter_by(owner_id=user.user['id']).one()
tag2 = Tag.from_an_id('foo').filter_by(owner_id=user2.user['id']).one() tag2 = Tag.from_an_id('foo').filter_by(owner_id=user2.user['id']).one()
pc1 = Desktop(serial_number='sn1', chassis=ComputerChassis.Tower, owner_id=user.user['id']) pc1 = Desktop(
pc2 = Desktop(serial_number='sn2', chassis=ComputerChassis.Tower, owner_id=user2.user['id']) serial_number='sn1', chassis=ComputerChassis.Tower, owner_id=user.user['id']
)
pc2 = Desktop(
serial_number='sn2', chassis=ComputerChassis.Tower, owner_id=user2.user['id']
)
pc1.tags.add(tag1) pc1.tags.add(tag1)
pc2.tags.add(tag2) pc2.tags.add(tag2)
db.session.add(pc1) db.session.add(pc1)
@ -266,7 +287,17 @@ def test_tag_create_etags_cli(app: Devicehub, user: UserClient):
# todo what happens to organization? # todo what happens to organization?
owner_id = user.user['id'] owner_id = user.user['id']
runner = app.test_cli_runner() runner = app.test_cli_runner()
args = ('tag', 'add', '-p', 'https://t.ereuse.org', '-s', 'foo', 'DT-BARBAR', '-u', owner_id) args = (
'tag',
'add',
'-p',
'https://t.ereuse.org',
'-s',
'foo',
'DT-BARBAR',
'-u',
owner_id,
)
runner.invoke(*args) runner.invoke(*args)
with app.app_context(): with app.app_context():
tag = Tag.query.one() # type: Tag tag = Tag.query.one() # type: Tag
@ -284,7 +315,11 @@ def test_tag_manual_link_search(app: Devicehub, user: UserClient):
with app.app_context(): with app.app_context():
g.user = User.query.one() g.user = User.query.one()
db.session.add(Tag('foo-bar', secondary='foo-sec', owner_id=user.user['id'])) db.session.add(Tag('foo-bar', secondary='foo-sec', owner_id=user.user['id']))
desktop = Desktop(serial_number='foo', chassis=ComputerChassis.AllInOne, owner_id=user.user['id']) desktop = Desktop(
serial_number='foo',
chassis=ComputerChassis.AllInOne,
owner_id=user.user['id'],
)
db.session.add(desktop) db.session.add(desktop)
db.session.commit() db.session.commit()
desktop_id = desktop.id desktop_id = desktop.id
@ -330,13 +365,21 @@ def test_tag_secondary_workbench_link_find(user: UserClient):
s['device']['tags'] = [{'id': 'foo', 'secondary': 'bar', 'type': 'Tag'}] s['device']['tags'] = [{'id': 'foo', 'secondary': 'bar', 'type': 'Tag'}]
snapshot, _ = user.post(json_encode(s), res=Snapshot) snapshot, _ = user.post(json_encode(s), res=Snapshot)
device, _ = user.get(res=Device, item=snapshot['device']['devicehubID']) device, _ = user.get(res=Device, item=snapshot['device']['devicehubID'])
assert 'foo' in [x['id'] for x in device['tags']] desktop = Device.query.filter_by(
assert 'bar' in [x.get('secondary') for x in device['tags']] devicehub_id=snapshot['device']['devicehubID']
).one()
assert ['O48N2'] == [x['id'] for x in device['tags']]
assert 'foo' in [x.id for x in desktop.binding.device.tags]
assert 'bar' in [x.secondary for x in desktop.binding.device.tags]
r, _ = user.get(res=Device, query=[('search', 'foo'), ('filter', {'type': ['Computer']})]) r, _ = user.get(
assert len(r['items']) == 1 res=Device, query=[('search', 'foo'), ('filter', {'type': ['Computer']})]
r, _ = user.get(res=Device, query=[('search', 'bar'), ('filter', {'type': ['Computer']})]) )
assert len(r['items']) == 1 assert len(r['items']) == 0
r, _ = user.get(
res=Device, query=[('search', 'bar'), ('filter', {'type': ['Computer']})]
)
assert len(r['items']) == 0
@pytest.mark.mvp @pytest.mark.mvp
@ -359,19 +402,24 @@ def test_tag_multiple_secondary_org(user: UserClient):
@pytest.mark.mvp @pytest.mark.mvp
def test_create_num_regular_tags(user: UserClient, requests_mock: requests_mock.mocker.Mocker): def test_create_num_regular_tags(
user: UserClient, requests_mock: requests_mock.mocker.Mocker
):
"""Create regular tags. This is done using a tag provider that """Create regular tags. This is done using a tag provider that
returns IDs. These tags are printable. returns IDs. These tags are printable.
""" """
requests_mock.post('https://example.com/', requests_mock.post(
# request 'https://example.com/',
request_headers={ # request
'Authorization': 'Basic {}'.format(DevicehubClient.encode_token( request_headers={
'52dacef0-6bcb-4919-bfed-f10d2c96ecee')) 'Authorization': 'Basic {}'.format(
}, DevicehubClient.encode_token('52dacef0-6bcb-4919-bfed-f10d2c96ecee')
# response )
json=['tag1id', 'tag2id'], },
status_code=201) # response
json=['tag1id', 'tag2id'],
status_code=201,
)
data, _ = user.post({}, res=Tag, query=[('num', 2)]) data, _ = user.post({}, res=Tag, query=[('num', 2)])
assert data['items'][0]['id'] == 'tag1id' assert data['items'][0]['id'] == 'tag1id'
assert data['items'][0]['printable'], 'Tags made this way are printable' assert data['items'][0]['printable'], 'Tags made this way are printable'
@ -380,28 +428,37 @@ def test_create_num_regular_tags(user: UserClient, requests_mock: requests_mock.
@pytest.mark.mvp @pytest.mark.mvp
def test_get_tags_endpoint(user: UserClient, app: Devicehub, def test_get_tags_endpoint(
requests_mock: requests_mock.mocker.Mocker): user: UserClient, app: Devicehub, requests_mock: requests_mock.mocker.Mocker
):
"""Performs GET /tags after creating 3 tags, 2 printable and one """Performs GET /tags after creating 3 tags, 2 printable and one
not. Only the printable ones are returned. not. Only the printable ones are returned.
""" """
# Prepare test # Prepare test
with app.app_context(): with app.app_context():
org = Organization(name='bar', tax_id='bartax') org = Organization(name='bar', tax_id='bartax')
tag = Tag(id='bar-1', org=org, provider=URL('http://foo.bar'), owner_id=user.user['id']) tag = Tag(
id='bar-1',
org=org,
provider=URL('http://foo.bar'),
owner_id=user.user['id'],
)
db.session.add(tag) db.session.add(tag)
db.session.commit() db.session.commit()
assert not tag.printable assert not tag.printable
requests_mock.post('https://example.com/', requests_mock.post(
# request 'https://example.com/',
request_headers={ # request
'Authorization': 'Basic {}'.format(DevicehubClient.encode_token( request_headers={
'52dacef0-6bcb-4919-bfed-f10d2c96ecee')) 'Authorization': 'Basic {}'.format(
}, DevicehubClient.encode_token('52dacef0-6bcb-4919-bfed-f10d2c96ecee')
# response )
json=['tag1id', 'tag2id'], },
status_code=201) # response
json=['tag1id', 'tag2id'],
status_code=201,
)
user.post({}, res=Tag, query=[('num', 2)]) user.post({}, res=Tag, query=[('num', 2)])
# Test itself # Test itself
@ -421,7 +478,9 @@ def test_get_tag_permissions(app: Devicehub, user: UserClient, user2: UserClient
# Create a pc with a tag # Create a pc with a tag
g.user = User.query.all()[0] g.user = User.query.all()[0]
tag = Tag(id='foo-bar', owner_id=user.user['id']) tag = Tag(id='foo-bar', owner_id=user.user['id'])
pc = Desktop(serial_number='sn1', chassis=ComputerChassis.Tower, owner_id=user.user['id']) pc = Desktop(
serial_number='sn1', chassis=ComputerChassis.Tower, owner_id=user.user['id']
)
pc.tags.add(tag) pc.tags.add(tag)
db.session.add(pc) db.session.add(pc)
db.session.commit() db.session.commit()

View File

@ -1,17 +1,21 @@
"""Tests that emulates the behaviour of a WorkbenchServer.""" """Tests that emulates the behaviour of a WorkbenchServer."""
import json import json
import math
import pathlib import pathlib
import math
import pytest import pytest
from ereuse_devicehub.client import UserClient from ereuse_devicehub.client import UserClient
from ereuse_devicehub.resources.action import models as em from ereuse_devicehub.resources.action import models as em
from ereuse_devicehub.resources.action.models import RateComputer, BenchmarkProcessor, BenchmarkRamSysbench from ereuse_devicehub.resources.action.models import (
BenchmarkProcessor,
BenchmarkRamSysbench,
RateComputer,
)
from ereuse_devicehub.resources.device.exceptions import NeedsId from ereuse_devicehub.resources.device.exceptions import NeedsId
from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.tag.model import Tag
from tests.conftest import file, file_workbench, yaml2json, json_encode from tests.conftest import file, file_workbench, json_encode, yaml2json
@pytest.mark.mvp @pytest.mark.mvp
@ -22,10 +26,9 @@ def test_workbench_server_condensed(user: UserClient):
""" """
s = yaml2json('workbench-server-1.snapshot') s = yaml2json('workbench-server-1.snapshot')
s['device']['actions'].append(yaml2json('workbench-server-2.stress-test')) s['device']['actions'].append(yaml2json('workbench-server-2.stress-test'))
s['components'][4]['actions'].extend(( s['components'][4]['actions'].extend(
yaml2json('workbench-server-3.erase'), (yaml2json('workbench-server-3.erase'), yaml2json('workbench-server-4.install'))
yaml2json('workbench-server-4.install') )
))
s['components'][5]['actions'].append(yaml2json('workbench-server-3.erase')) s['components'][5]['actions'].append(yaml2json('workbench-server-3.erase'))
# Create tags # Create tags
for t in s['device']['tags']: for t in s['device']['tags']:
@ -34,7 +37,7 @@ def test_workbench_server_condensed(user: UserClient):
snapshot, _ = user.post(res=em.Snapshot, data=json_encode(s)) snapshot, _ = user.post(res=em.Snapshot, data=json_encode(s))
pc_id = snapshot['device']['id'] pc_id = snapshot['device']['id']
cpu_id = snapshot['components'][3]['id'] cpu_id = snapshot['components'][3]['id']
ssd_id= snapshot['components'][4]['id'] ssd_id = snapshot['components'][4]['id']
hdd_id = snapshot['components'][5]['id'] hdd_id = snapshot['components'][5]['id']
actions = snapshot['actions'] actions = snapshot['actions']
assert {(action['type'], action['device']) for action in actions} == { assert {(action['type'], action['device']) for action in actions} == {
@ -60,8 +63,13 @@ def test_workbench_server_condensed(user: UserClient):
assert device['processorModel'] == device['components'][3]['model'] == 'p1-1ml' assert device['processorModel'] == device['components'][3]['model'] == 'p1-1ml'
assert device['ramSize'] == 2048, 'There are 3 RAM: 2 x 1024 and 1 None sizes' assert device['ramSize'] == 2048, 'There are 3 RAM: 2 x 1024 and 1 None sizes'
# TODO JN why haven't same order in actions on each execution? # TODO JN why haven't same order in actions on each execution?
assert any([ac['type'] in [BenchmarkProcessor.t, BenchmarkRamSysbench.t] for ac in device['actions']]) assert any(
assert 'tag1' in [x['id'] for x in device['tags']] [
ac['type'] in [BenchmarkProcessor.t, BenchmarkRamSysbench.t]
for ac in device['actions']
]
)
assert 'tag1' not in [x['id'] for x in device['tags']]
@pytest.mark.xfail(reason='Functionality not yet developed.') @pytest.mark.xfail(reason='Functionality not yet developed.')
@ -136,7 +144,10 @@ def test_real_hp_11(user: UserClient):
s = file('real-hp.snapshot.11') s = file('real-hp.snapshot.11')
snapshot, _ = user.post(res=em.Snapshot, data=s) snapshot, _ = user.post(res=em.Snapshot, data=s)
pc = snapshot['device'] pc = snapshot['device']
assert pc['hid'] == 'desktop-hewlett-packard-hp_compaq_8100_elite_sff-czc0408yjg-6c:62:6d:81:22:9f' assert (
pc['hid']
== 'desktop-hewlett-packard-hp_compaq_8100_elite_sff-czc0408yjg-6c:62:6d:81:22:9f'
)
assert pc['chassis'] == 'Tower' assert pc['chassis'] == 'Tower'
assert set(e['type'] for e in snapshot['actions']) == { assert set(e['type'] for e in snapshot['actions']) == {
'BenchmarkDataStorage', 'BenchmarkDataStorage',
@ -146,7 +157,7 @@ def test_real_hp_11(user: UserClient):
'BenchmarkRamSysbench', 'BenchmarkRamSysbench',
'StressTest', 'StressTest',
'TestBios', 'TestBios',
'VisualTest' 'VisualTest',
} }
assert len(list(e['type'] for e in snapshot['actions'])) == 8 assert len(list(e['type'] for e in snapshot['actions'])) == 8
@ -177,22 +188,32 @@ def test_snapshot_real_eee_1001pxd_with_rate(user: UserClient):
assert pc['model'] == '1001pxd' assert pc['model'] == '1001pxd'
assert pc['serialNumber'] == 'b8oaas048286' assert pc['serialNumber'] == 'b8oaas048286'
assert pc['manufacturer'] == 'asustek computer inc.' assert pc['manufacturer'] == 'asustek computer inc.'
assert pc['hid'] == 'laptop-asustek_computer_inc-1001pxd-b8oaas048286-14:da:e9:42:f6:7c' assert (
pc['hid']
== 'laptop-asustek_computer_inc-1001pxd-b8oaas048286-14:da:e9:42:f6:7c'
)
assert len(pc['tags']) == 1 assert len(pc['tags']) == 1
assert pc['networkSpeeds'] == [100, 0], 'Although it has WiFi we do not know the speed' assert pc['networkSpeeds'] == [
100,
0,
], 'Although it has WiFi we do not know the speed'
# assert pc['actions'][0]['appearanceRange'] == 'A' # assert pc['actions'][0]['appearanceRange'] == 'A'
# assert pc['actions'][0]['functionalityRange'] == 'B' # assert pc['actions'][0]['functionalityRange'] == 'B'
# TODO add appearance and functionality Range in device[rate] # TODO add appearance and functionality Range in device[rate]
components = snapshot['components'] components = snapshot['components']
wifi = components[0] wifi = components[0]
assert wifi['hid'] == 'networkadapter-qualcomm_atheros-' \ assert (
'ar9285_wireless_network_adapter-74_2f_68_8b_fd_c8' wifi['hid'] == 'networkadapter-qualcomm_atheros-'
'ar9285_wireless_network_adapter-74_2f_68_8b_fd_c8'
)
assert wifi['serialNumber'] == '74:2f:68:8b:fd:c8' assert wifi['serialNumber'] == '74:2f:68:8b:fd:c8'
assert wifi['wireless'] assert wifi['wireless']
eth = components[1] eth = components[1]
assert eth['hid'] == 'networkadapter-qualcomm_atheros-' \ assert (
'ar8152_v2_0_fast_ethernet-14_da_e9_42_f6_7c' eth['hid'] == 'networkadapter-qualcomm_atheros-'
'ar8152_v2_0_fast_ethernet-14_da_e9_42_f6_7c'
)
assert eth['speed'] == 100 assert eth['speed'] == 100
assert not eth['wireless'] assert not eth['wireless']
cpu = components[2] cpu = components[2]
@ -219,7 +240,10 @@ def test_snapshot_real_eee_1001pxd_with_rate(user: UserClient):
assert em.Snapshot.t in action_types assert em.Snapshot.t in action_types
assert len(actions) == 6 assert len(actions) == 6
gpu = components[3] gpu = components[3]
assert gpu['model'] == 'atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller' assert (
gpu['model']
== 'atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller'
)
assert gpu['manufacturer'] == 'intel corporation' assert gpu['manufacturer'] == 'intel corporation'
assert gpu['memory'] == 256 assert gpu['memory'] == 256
gpu, _ = user.get(res=Device, item=gpu['devicehubID']) gpu, _ = user.get(res=Device, item=gpu['devicehubID'])
@ -285,25 +309,26 @@ SNAPSHOTS_NEED_ID = {
'nox.snapshot.json', 'nox.snapshot.json',
'ecs-computers.snapshot.json', 'ecs-computers.snapshot.json',
'custom.snapshot.json', 'custom.snapshot.json',
'ecs-2.snapshot.json' 'ecs-2.snapshot.json',
} }
"""Snapshots that do not generate HID requiring a custom ID.""" """Snapshots that do not generate HID requiring a custom ID."""
@pytest.mark.mvp @pytest.mark.mvp
@pytest.mark.parametrize('file', @pytest.mark.parametrize(
(pytest.param(f, id=f.name) 'file',
for f in pathlib.Path(__file__).parent.joinpath('workbench_files').iterdir()) (
) pytest.param(f, id=f.name)
for f in pathlib.Path(__file__).parent.joinpath('workbench_files').iterdir()
),
)
def test_workbench_fixtures(file: pathlib.Path, user: UserClient): def test_workbench_fixtures(file: pathlib.Path, user: UserClient):
"""Uploads the Snapshot files Workbench tests generate. """Uploads the Snapshot files Workbench tests generate.
Keep this files up to date with the Workbench version. Keep this files up to date with the Workbench version.
""" """
s = json.load(file.open()) s = json.load(file.open())
user.post(res=em.Snapshot, user.post(res=em.Snapshot, data=json_encode(s), status=201)
data=json_encode(s),
status=201)
@pytest.mark.mvp @pytest.mark.mvp