precommit
This commit is contained in:
parent
bd3befa0af
commit
028f3c8e74
|
@ -78,7 +78,6 @@ class SnapshotMix:
|
||||||
components = snapshot_json.pop('components', None) # type: List[Component]
|
components = snapshot_json.pop('components', None) # type: List[Component]
|
||||||
if isinstance(device, Computer) and device.hid:
|
if isinstance(device, Computer) and device.hid:
|
||||||
device.add_mac_to_hid(components_snap=components)
|
device.add_mac_to_hid(components_snap=components)
|
||||||
# import pdb; pdb.set_trace()
|
|
||||||
snapshot = Snapshot(**snapshot_json)
|
snapshot = Snapshot(**snapshot_json)
|
||||||
|
|
||||||
# Remove new actions from devices so they don't interfere with sync
|
# Remove new actions from devices so they don't interfere with sync
|
||||||
|
|
|
@ -4,9 +4,9 @@ import shutil
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
from pathlib import Path
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from boltons import urlutils
|
from boltons import urlutils
|
||||||
|
@ -962,7 +962,9 @@ def test_bug_141(user: UserClient):
|
||||||
def test_snapshot_wb_lite(user: UserClient):
|
def test_snapshot_wb_lite(user: UserClient):
|
||||||
"""This test check the minimum validation of json that come from snapshot"""
|
"""This test check the minimum validation of json that come from snapshot"""
|
||||||
|
|
||||||
snapshot = file_json("2022-03-31_17h18m51s_ZQMPKKX51K67R68VO2X9RNZL08JPL_snapshot.json")
|
snapshot = file_json(
|
||||||
|
"2022-03-31_17h18m51s_ZQMPKKX51K67R68VO2X9RNZL08JPL_snapshot.json"
|
||||||
|
)
|
||||||
body, res = user.post(snapshot, uri="/api/inventory/")
|
body, res = user.post(snapshot, uri="/api/inventory/")
|
||||||
|
|
||||||
ssd = [x for x in body['components'] if x['type'] == 'SolidStateDrive'][0]
|
ssd = [x for x in body['components'] if x['type'] == 'SolidStateDrive'][0]
|
||||||
|
@ -1022,12 +1024,7 @@ def test_snapshot_wb_lite_old_snapshots(user: UserClient):
|
||||||
'software': 'Workbench',
|
'software': 'Workbench',
|
||||||
'version': '2022.03.00',
|
'version': '2022.03.00',
|
||||||
"schema_version": "V1",
|
"schema_version": "V1",
|
||||||
'data': {
|
'data': {'lshw': lshw, 'hwinfo': hwinfo, 'smart': [], 'dmidecode': ''},
|
||||||
'lshw': lshw,
|
|
||||||
'hwinfo': hwinfo,
|
|
||||||
'smart': [],
|
|
||||||
'dmidecode': ''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body11, res = user.post(snapshot_11, res=Snapshot)
|
body11, res = user.post(snapshot_11, res=Snapshot)
|
||||||
|
@ -1037,25 +1034,21 @@ def test_snapshot_wb_lite_old_snapshots(user: UserClient):
|
||||||
for c in body11.get('components', []):
|
for c in body11.get('components', []):
|
||||||
if c['type'] in ["HardDrive", "SolidStateDrive"]:
|
if c['type'] in ["HardDrive", "SolidStateDrive"]:
|
||||||
continue
|
continue
|
||||||
components11.append({
|
components11.append({c.get('model'), c['type'], c.get('manufacturer')})
|
||||||
c.get('model'),
|
|
||||||
c['type'],
|
|
||||||
c.get('manufacturer')
|
|
||||||
})
|
|
||||||
for c in bodyLite.get('components', []):
|
for c in bodyLite.get('components', []):
|
||||||
componentsLite.append({
|
componentsLite.append({c.get('model'), c['type'], c.get('manufacturer')})
|
||||||
c.get('model'),
|
|
||||||
c['type'],
|
|
||||||
c.get('manufacturer')
|
|
||||||
})
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
assert body11['device'].get('hid') == bodyLite['device'].get('hid')
|
assert body11['device'].get('hid') == bodyLite['device'].get('hid')
|
||||||
if body11['device'].get('hid'):
|
if body11['device'].get('hid'):
|
||||||
assert body11['device']['id'] == bodyLite['device']['id']
|
assert body11['device']['id'] == bodyLite['device']['id']
|
||||||
assert body11['device'].get('serialNumber') == bodyLite['device'].get('serialNumber')
|
assert body11['device'].get('serialNumber') == bodyLite['device'].get(
|
||||||
|
'serialNumber'
|
||||||
|
)
|
||||||
assert body11['device'].get('model') == bodyLite['device'].get('model')
|
assert body11['device'].get('model') == bodyLite['device'].get('model')
|
||||||
assert body11['device'].get('manufacturer') == bodyLite['device'].get('manufacturer')
|
assert body11['device'].get('manufacturer') == bodyLite['device'].get(
|
||||||
|
'manufacturer'
|
||||||
|
)
|
||||||
|
|
||||||
# wbLite can find more components than wb11
|
# wbLite can find more components than wb11
|
||||||
assert len(components11) <= len(componentsLite)
|
assert len(components11) <= len(componentsLite)
|
||||||
|
@ -1081,12 +1074,7 @@ def test_snapshot_errors(user: UserClient):
|
||||||
'software': 'Workbench',
|
'software': 'Workbench',
|
||||||
'version': '2022.03.00',
|
'version': '2022.03.00',
|
||||||
"schema_version": "V1",
|
"schema_version": "V1",
|
||||||
'data': {
|
'data': {'lshw': lshw, 'hwinfo': hwinfo, 'smart': [], 'dmidecode': ''},
|
||||||
'lshw': lshw,
|
|
||||||
'hwinfo': hwinfo,
|
|
||||||
'smart': [],
|
|
||||||
'dmidecode': ''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert SnapshotErrors.query.all() == []
|
assert SnapshotErrors.query.all() == []
|
||||||
|
@ -1097,25 +1085,21 @@ def test_snapshot_errors(user: UserClient):
|
||||||
|
|
||||||
assert body11['device'].get('hid') == bodyLite['device'].get('hid')
|
assert body11['device'].get('hid') == bodyLite['device'].get('hid')
|
||||||
assert body11['device']['id'] == bodyLite['device']['id']
|
assert body11['device']['id'] == bodyLite['device']['id']
|
||||||
assert body11['device'].get('serialNumber') == bodyLite['device'].get('serialNumber')
|
assert body11['device'].get('serialNumber') == bodyLite['device'].get(
|
||||||
|
'serialNumber'
|
||||||
|
)
|
||||||
assert body11['device'].get('model') == bodyLite['device'].get('model')
|
assert body11['device'].get('model') == bodyLite['device'].get('model')
|
||||||
assert body11['device'].get('manufacturer') == bodyLite['device'].get('manufacturer')
|
assert body11['device'].get('manufacturer') == bodyLite['device'].get(
|
||||||
|
'manufacturer'
|
||||||
|
)
|
||||||
components11 = []
|
components11 = []
|
||||||
componentsLite = []
|
componentsLite = []
|
||||||
for c in body11['components']:
|
for c in body11['components']:
|
||||||
if c['type'] == "HardDrive":
|
if c['type'] == "HardDrive":
|
||||||
continue
|
continue
|
||||||
components11.append({
|
components11.append({c['model'], c['type'], c['manufacturer']})
|
||||||
c['model'],
|
|
||||||
c['type'],
|
|
||||||
c['manufacturer']
|
|
||||||
})
|
|
||||||
for c in bodyLite['components']:
|
for c in bodyLite['components']:
|
||||||
componentsLite.append({
|
componentsLite.append({c['model'], c['type'], c['manufacturer']})
|
||||||
c['model'],
|
|
||||||
c['type'],
|
|
||||||
c['manufacturer']
|
|
||||||
})
|
|
||||||
|
|
||||||
assert len(components11) == len(componentsLite)
|
assert len(components11) == len(componentsLite)
|
||||||
for c in components11:
|
for c in components11:
|
||||||
|
|
Reference in New Issue