add wbid in the snapshots

This commit is contained in:
Cayo Puigdefabregas 2022-03-30 13:48:55 +02:00
parent 4881aac5c9
commit ca71494e2b
6 changed files with 476 additions and 294 deletions

View File

@ -5,6 +5,7 @@ Revises: 8571fb32c912
Create Date: 2022-03-29 11:49:39.270791
"""
import citext
import sqlalchemy as sa
from alembic import context, op
from sqlalchemy.dialects import postgresql
@ -29,7 +30,13 @@ def upgrade():
sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=True),
schema=f'{get_inv()}',
)
op.add_column(
'snapshot',
sa.Column('wbid', citext.CIText(), nullable=True),
schema=f'{get_inv()}',
)
def downgrade():
op.drop_column('computer', 'uuid', schema=f'{get_inv()}')
op.drop_column('snapshot', 'wbid', schema=f'{get_inv()}')

View File

@ -33,6 +33,7 @@ class ParseSnapshot:
"version": snapshot["version"],
"endTime": snapshot["timestamp"],
"elapsed": 1,
"wbid": snapshot["wbid"],
}
def set_basic_datas(self):
@ -339,6 +340,7 @@ class ParseSnapshotLsHw:
"version": snapshot["version"],
"endTime": snapshot["timestamp"],
"elapsed": 1,
"wbid": snapshot["wbid"],
}
def parse_hwinfo(self):

File diff suppressed because it is too large Load Diff

View File

@ -424,10 +424,12 @@ class Snapshot_lite_data(MarshmallowSchema):
class Snapshot_lite(MarshmallowSchema):
uuid = String()
version = String()
type = String()
timestamp = String()
uuid = String(required=True)
version = String(required=True)
software = String(required=True)
wbid = String(required=True)
type = String(required=True)
timestamp = String(required=True)
data = Nested(Snapshot_lite_data)
@validates_schema
@ -451,6 +453,7 @@ class Snapshot(ActionWithOneDevice):
See docs for more info.
"""
uuid = UUID()
wbid = String(required=False)
software = EnumField(
SnapshotSoftware,
required=True,

File diff suppressed because one or more lines are too long

View File

@ -274,9 +274,7 @@ def test_snapshot_component_add_remove(user: UserClient):
s3 = yaml2json(
'3-first-device-but-removing-motherboard-and-adding-processor-from-2.snapshot'
)
snapshot_and_check(
user, s3, ('Remove',), perform_second_snapshot=False
)
snapshot_and_check(user, s3, ('Remove',), perform_second_snapshot=False)
pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id)
pc2, _ = user.get(res=m.Device, item=pc2_devicehub_id)
# Check if the update_timestamp is updated
@ -365,9 +363,7 @@ def test_snapshot_tag_inner_tag(user: UserClient, tag_id: str, app: Devicehub):
b = yaml2json('basic.snapshot')
b['device']['tags'] = [{'type': 'Tag', 'id': tag_id}]
snapshot_and_check(
user, b, action_types=(BenchmarkProcessor.t, VisualTest.t)
)
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'
@ -970,6 +966,7 @@ def test_snapshot_wb_lite(user: UserClient):
ssd = [x for x in body['components'] if x['type'] == 'SolidStateDrive'][0]
assert body['device']['manufacturer'] == 'lenovo'
assert body['wbid'] == "LXVC"
assert ssd['serialNumber'] == 's35anx0j'
assert res.status == '201 CREATED'
assert '00:28:f8:a6:d5:7e' in body['device']['hid']