fixing tests
This commit is contained in:
parent
d2975ba313
commit
a222b37ecc
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -54,6 +54,7 @@ def test_api_docs(client: Client):
|
||||||
'/inventory/device/',
|
'/inventory/device/',
|
||||||
'/inventory/device/add/',
|
'/inventory/device/add/',
|
||||||
'/inventory/device/{id}/',
|
'/inventory/device/{id}/',
|
||||||
|
'/inventory/device/{dhid}/binding/',
|
||||||
'/inventory/export/{export_id}/',
|
'/inventory/export/{export_id}/',
|
||||||
'/inventory/lot/add/',
|
'/inventory/lot/add/',
|
||||||
'/inventory/lot/{id}/',
|
'/inventory/lot/{id}/',
|
||||||
|
@ -68,8 +69,8 @@ def test_api_docs(client: Client):
|
||||||
'/inventory/lot/{lot_id}/upload-snapshot/',
|
'/inventory/lot/{lot_id}/upload-snapshot/',
|
||||||
'/inventory/snapshots/{snapshot_uuid}/',
|
'/inventory/snapshots/{snapshot_uuid}/',
|
||||||
'/inventory/snapshots/',
|
'/inventory/snapshots/',
|
||||||
'/inventory/tag/devices/add/',
|
'/inventory/tag/devices/{dhid}/add/',
|
||||||
'/inventory/tag/devices/{id}/del/',
|
'/inventory/tag/devices/{dhid}/del/',
|
||||||
'/inventory/upload-snapshot/',
|
'/inventory/upload-snapshot/',
|
||||||
'/inventory/device/edit/{id}/',
|
'/inventory/device/edit/{id}/',
|
||||||
'/inventory/upload-placeholder/',
|
'/inventory/upload-placeholder/',
|
||||||
|
|
|
@ -473,14 +473,17 @@ def test_get_devices(app: Devicehub, user: UserClient):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.mvp
|
@pytest.mark.mvp
|
||||||
def test_get_device_permissions(app: Devicehub, user: UserClient, user2: UserClient,
|
@pytest.mark.usefixtures(conftest.app_context.__name__)
|
||||||
|
def test_get_device_permissions(app: Devicehub, user: UserClient, user2: UserClient,
|
||||||
client: Client):
|
client: Client):
|
||||||
"""Checks GETting a d.Desktop with its components."""
|
"""Checks GETting a d.Desktop with its components."""
|
||||||
|
|
||||||
s, _ = user.post(file('asus-eee-1000h.snapshot.11'), res=m.Snapshot)
|
s, _ = user.post(file('asus-eee-1000h.snapshot.11'), res=m.Snapshot)
|
||||||
pc, res = user.get(res=d.Device, item=s['device']['devicehubID'])
|
pc, res = user.get(res=d.Device, item=s['device']['devicehubID'])
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
assert len(pc['actions']) == 7
|
assert len(pc['actions']) == 0
|
||||||
|
pc = d.Device.query.filter_by(devicehub_id=s['device']['devicehubID']).one()
|
||||||
|
assert len(pc.placeholder.binding.actions) == 7
|
||||||
|
|
||||||
html, _ = client.get(res=d.Device, item=s['device']['devicehubID'], accept=ANY)
|
html, _ = client.get(res=d.Device, item=s['device']['devicehubID'], accept=ANY)
|
||||||
assert 'intel atom cpu n270 @ 1.60ghz' in html
|
assert 'intel atom cpu n270 @ 1.60ghz' in html
|
||||||
|
@ -660,12 +663,15 @@ def test_cooking_mixer_api(user: UserClient):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.mvp
|
@pytest.mark.mvp
|
||||||
|
@pytest.mark.usefixtures(conftest.app_context.__name__)
|
||||||
def test_hid_with_mac(app: Devicehub, user: UserClient):
|
def test_hid_with_mac(app: Devicehub, user: UserClient):
|
||||||
"""Checks hid with mac."""
|
"""Checks hid with mac."""
|
||||||
snapshot = file('asus-eee-1000h.snapshot.11')
|
snapshot = file('asus-eee-1000h.snapshot.11')
|
||||||
snap, _ = user.post(snapshot, res=m.Snapshot)
|
snap, _ = user.post(snapshot, res=m.Snapshot)
|
||||||
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
||||||
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d'
|
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116'
|
||||||
|
pc = d.Device.query.filter_by(devicehub_id=snap['device']['devicehubID']).one()
|
||||||
|
assert pc.placeholder.binding.hid == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.mvp
|
@pytest.mark.mvp
|
||||||
|
@ -706,6 +712,7 @@ def test_hid_with_2networkadapters(app: Devicehub, user: UserClient):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.mvp
|
@pytest.mark.mvp
|
||||||
|
@pytest.mark.usefixtures(conftest.app_context.__name__)
|
||||||
def test_hid_with_2network_and_drop_no_mac_in_hid(app: Devicehub, user: UserClient):
|
def test_hid_with_2network_and_drop_no_mac_in_hid(app: Devicehub, user: UserClient):
|
||||||
"""Checks hid with 2 networks adapters and next drop the network is not used in hid"""
|
"""Checks hid with 2 networks adapters and next drop the network is not used in hid"""
|
||||||
snapshot = yaml2json('asus-eee-1000h.snapshot.11')
|
snapshot = yaml2json('asus-eee-1000h.snapshot.11')
|
||||||
|
@ -715,19 +722,22 @@ def test_hid_with_2network_and_drop_no_mac_in_hid(app: Devicehub, user: UserClie
|
||||||
network['serialNumber'] = 'a0:24:8c:7f:cf:2d'
|
network['serialNumber'] = 'a0:24:8c:7f:cf:2d'
|
||||||
snap, _ = user.post(json_encode(snapshot), res=m.Snapshot)
|
snap, _ = user.post(json_encode(snapshot), res=m.Snapshot)
|
||||||
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
||||||
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d'
|
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116'
|
||||||
|
pc = d.Device.query.filter_by(devicehub_id=snap['device']['devicehubID']).one()
|
||||||
|
assert pc.placeholder.binding.hid == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d'
|
||||||
|
|
||||||
snapshot['uuid'] = 'd1b70cb8-8929-4f36-99b7-fe052cec0abb'
|
snapshot['uuid'] = 'd1b70cb8-8929-4f36-99b7-fe052cec0abb'
|
||||||
snapshot['components'] = [c for c in snapshot['components'] if c != network]
|
snapshot['components'] = [c for c in snapshot['components'] if c != network]
|
||||||
user.post(json_encode(snapshot), res=m.Snapshot)
|
user.post(json_encode(snapshot), res=m.Snapshot)
|
||||||
devices, _ = user.get(res=d.Device)
|
devices, _ = user.get(res=d.Device)
|
||||||
laptop = devices['items'][0]
|
laptop = devices['items'][0]
|
||||||
assert laptop['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d'
|
assert pc.placeholder.binding.hid == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d'
|
||||||
assert len([c for c in devices['items'] if c['type'] == 'Laptop']) == 2
|
assert len([c for c in devices['items'] if c['type'] == 'Laptop']) == 2
|
||||||
assert len([c for c in laptop['components'] if c['type'] == 'NetworkAdapter']) == 1
|
assert len([c for c in laptop['components'] if c['type'] == 'NetworkAdapter']) == 1
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.mvp
|
@pytest.mark.mvp
|
||||||
|
@pytest.mark.usefixtures(conftest.app_context.__name__)
|
||||||
def test_hid_with_2network_and_drop_mac_in_hid(app: Devicehub, user: UserClient):
|
def test_hid_with_2network_and_drop_mac_in_hid(app: Devicehub, user: UserClient):
|
||||||
"""Checks hid with 2 networks adapters and next drop the network is used in hid"""
|
"""Checks hid with 2 networks adapters and next drop the network is used in hid"""
|
||||||
# One tipical snapshot with 2 network cards
|
# One tipical snapshot with 2 network cards
|
||||||
|
@ -738,7 +748,9 @@ def test_hid_with_2network_and_drop_mac_in_hid(app: Devicehub, user: UserClient)
|
||||||
network['serialNumber'] = 'a0:24:8c:7f:cf:2d'
|
network['serialNumber'] = 'a0:24:8c:7f:cf:2d'
|
||||||
snap, _ = user.post(json_encode(snapshot), res=m.Snapshot)
|
snap, _ = user.post(json_encode(snapshot), res=m.Snapshot)
|
||||||
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
||||||
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d'
|
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116'
|
||||||
|
pc = d.Device.query.filter_by(devicehub_id=snap['device']['devicehubID']).one()
|
||||||
|
assert pc.placeholder.binding.hid == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d'
|
||||||
|
|
||||||
# we drop the network card then is used for to build the hid
|
# we drop the network card then is used for to build the hid
|
||||||
snapshot['uuid'] = 'd1b70cb8-8929-4f36-99b7-fe052cec0abb'
|
snapshot['uuid'] = 'd1b70cb8-8929-4f36-99b7-fe052cec0abb'
|
||||||
|
|
|
@ -320,16 +320,16 @@ def test_link_tag_to_device(user3: UserClientFlask):
|
||||||
}
|
}
|
||||||
user3.post(uri, data=data)
|
user3.post(uri, data=data)
|
||||||
|
|
||||||
body, status = user3.get('/inventory/device/')
|
body, status = user3.get('/inventory/device/{}/'.format(dev.dhid))
|
||||||
assert "tag1" in body
|
assert "tag1" in body
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'tag': "tag1",
|
'tag': "tag1",
|
||||||
'device': dev.id,
|
'device': dev.dhid,
|
||||||
'csrf_token': generate_csrf(),
|
'csrf_token': generate_csrf(),
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = '/inventory/tag/devices/add/'
|
uri = '/inventory/tag/devices/{}/add/'.format(dev.dhid)
|
||||||
user3.post(uri, data=data)
|
user3.post(uri, data=data)
|
||||||
assert len(list(dev.tags)) == 1
|
assert len(list(dev.tags)) == 1
|
||||||
tags = [tag.id for tag in dev.tags]
|
tags = [tag.id for tag in dev.tags]
|
||||||
|
@ -406,7 +406,7 @@ def test_print_labels(user3: UserClientFlask):
|
||||||
'csrf_token': generate_csrf(),
|
'csrf_token': generate_csrf(),
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = '/inventory/tag/devices/add/'
|
uri = '/inventory/tag/devices/{}/add/'.format(dev.dhid)
|
||||||
user3.post(uri, data=data)
|
user3.post(uri, data=data)
|
||||||
|
|
||||||
assert len(list(dev.tags)) == 1
|
assert len(list(dev.tags)) == 1
|
||||||
|
@ -419,7 +419,7 @@ def test_print_labels(user3: UserClientFlask):
|
||||||
body, status = user3.post(uri, data=data)
|
body, status = user3.post(uri, data=data)
|
||||||
|
|
||||||
assert status == '200 OK'
|
assert status == '200 OK'
|
||||||
path = "/devices/{}".format(dev.devicehub_id)
|
path = "/devices/{}".format(dev.dhid)
|
||||||
assert path in body
|
assert path in body
|
||||||
assert "tag1" in body
|
assert "tag1" in body
|
||||||
|
|
||||||
|
@ -2021,7 +2021,6 @@ def test_manual_binding(user3: UserClientFlask):
|
||||||
'model': "LC27T55",
|
'model': "LC27T55",
|
||||||
'manufacturer': "Samsung",
|
'manufacturer': "Samsung",
|
||||||
'generation': 1,
|
'generation': 1,
|
||||||
'weight': 0.1,
|
|
||||||
'height': 0.1,
|
'height': 0.1,
|
||||||
'depth': 0.1,
|
'depth': 0.1,
|
||||||
'id_device_supplier': "b2",
|
'id_device_supplier': "b2",
|
||||||
|
@ -2047,17 +2046,24 @@ def test_manual_binding(user3: UserClientFlask):
|
||||||
old_placeholder = dev_wb.binding
|
old_placeholder = dev_wb.binding
|
||||||
|
|
||||||
# page binding
|
# page binding
|
||||||
dhid = dev_wb.devicehub_id
|
dhid = dev_wb.dhid
|
||||||
uri = f'/inventory/binding/{dhid}/sid/'
|
uri = f'/inventory/binding/{dhid}/sid/'
|
||||||
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
|
||||||
assert 'Confirm' in body
|
assert 'Confirm' in body
|
||||||
|
|
||||||
|
phid_real = dev.placeholder.phid
|
||||||
|
phid_abstract = dev_wb.binding.phid
|
||||||
|
dhid_real = dev.dhid
|
||||||
|
dhid_abstract = dev_wb.dhid
|
||||||
|
|
||||||
# action binding
|
# action binding
|
||||||
body, status = user3.post(uri, data={})
|
body, status = user3.post(uri, data={})
|
||||||
assert status == '200 OK'
|
assert status == '200 OK'
|
||||||
assert f"Device "{dhid}" bind successfully with sid!" in body
|
txt = f"Device real with PHID: {phid_real} and DHID: {dhid_real} "
|
||||||
|
txt += f"bind successfully with device abstract PHID: {phid_abstract} DHID: {dhid_abstract}."
|
||||||
|
assert txt in body
|
||||||
|
|
||||||
# check new structure
|
# check new structure
|
||||||
assert dev_wb.binding.phid == 'sid'
|
assert dev_wb.binding.phid == 'sid'
|
||||||
|
@ -2145,7 +2151,7 @@ def test_unbinding(user3: UserClientFlask):
|
||||||
old_placeholder = dev_wb.binding
|
old_placeholder = dev_wb.binding
|
||||||
|
|
||||||
# page binding
|
# page binding
|
||||||
dhid = dev_wb.devicehub_id
|
dhid = dev_wb.dhid
|
||||||
uri = f'/inventory/binding/{dhid}/sid/'
|
uri = f'/inventory/binding/{dhid}/sid/'
|
||||||
user3.get(uri)
|
user3.get(uri)
|
||||||
|
|
||||||
|
@ -2154,11 +2160,14 @@ def test_unbinding(user3: UserClientFlask):
|
||||||
user3.post(uri, data={})
|
user3.post(uri, data={})
|
||||||
assert dev.placeholder.binding == dev_wb
|
assert dev.placeholder.binding == dev_wb
|
||||||
|
|
||||||
|
dhid = dev.dhid
|
||||||
# action unbinding
|
# action unbinding
|
||||||
uri = '/inventory/unbinding/sid/'
|
uri = '/inventory/unbinding/sid/'
|
||||||
body, status = user3.post(uri, data={})
|
body, status = user3.post(uri, data={})
|
||||||
assert status == '200 OK'
|
assert status == '200 OK'
|
||||||
assert 'Device "sid" unbind successfully!' in body
|
txt = f'Device with PHID:"sid" and DHID: {dhid} unbind successfully!'
|
||||||
|
assert txt in body
|
||||||
|
# assert 'Device "sid" unbind successfully!' in body
|
||||||
|
|
||||||
# check new structure
|
# check new structure
|
||||||
|
|
||||||
|
|
Reference in New Issue