change schema_version for schema_api

This commit is contained in:
Cayo Puigdefabregas 2022-04-08 16:46:57 +02:00
parent 50d0dffc16
commit 09738478ae
6 changed files with 25 additions and 10 deletions

View File

@ -63,7 +63,7 @@ class DevicehubConfig(Config):
"""The minimum version of ereuse.org workbench that this devicehub
accepts. we recommend not changing this value.
"""
WORKBENCH_LITE = ["V1"]
WORKBENCH_LITE = ["1.0.0"]
TMP_SNAPSHOTS = config('TMP_SNAPSHOTS', '/tmp/snapshots')
TMP_LIVES = config('TMP_LIVES', '/tmp/lives')

View File

@ -253,7 +253,7 @@ class UploadSnapshotForm(FlaskForm, SnapshotMix):
for filename, snapshot_json in self.snapshots:
path_snapshot = save_json(snapshot_json, self.tmp_snapshots, g.user.email)
snapshot_json.pop('debug', None)
version = snapshot_json.get('schema_version')
version = snapshot_json.get('schema_api')
if self.is_wb_lite_snapshot(version):
self.snapshot_json = schema_lite.load(snapshot_json)
snapshot_json = ParseSnapshotLsHw(self.snapshot_json).snapshot_json

View File

@ -11,12 +11,13 @@ class Snapshot_lite_data(MarshmallowSchema):
hwinfo = String(required=False)
smart = List(Dict(), required=False)
lshw = Dict(required=False)
lspci = String(required=False)
class Snapshot_lite(Thing):
uuid = String(required=True)
version = String(required=True)
schema_version = String(required=True)
schema_api = String(required=True)
software = String(required=True)
wbid = String(required=True)
type = String(required=True)
@ -25,7 +26,7 @@ class Snapshot_lite(Thing):
@validates_schema
def validate_workbench_version(self, data: dict):
if data['schema_version'] not in app.config['WORKBENCH_LITE']:
if data['schema_api'] not in app.config['WORKBENCH_LITE']:
raise ValidationError(
'Min. supported Workbench version is '
'{} but yours is {}.'.format(

View File

@ -5,8 +5,9 @@
"wbid": "MLKO1Y0R55XZM051WQ5KJM01RY44Q",
"software": "Workbench",
"version": "2022.03.00",
"schema_version": "V1",
"schema_api": "1.0.0",
"data": {
"lspci": "",
"lshw": {
"id": "__",
"class": "system",

View File

@ -5,8 +5,9 @@
"wbid": "YKPZ27NJ2NMRO4893M4L5NRZV5YJ1",
"software": "Workbench",
"version": "2022.03.00",
"schema_version": "V1",
"schema_api": "1.0.0",
"data": {
"lspci": "",
"lshw": {
"id": "wb",
"class": "system",

View File

@ -1023,8 +1023,14 @@ def test_snapshot_wb_lite_old_snapshots(user: UserClient):
'wbid': 'MLKO1',
'software': 'Workbench',
'version': '2022.03.00',
"schema_version": "V1",
'data': {'lshw': lshw, 'hwinfo': hwinfo, 'smart': [], 'dmidecode': ''},
"schema_api": "1.0.0",
'data': {
'lshw': lshw,
'hwinfo': hwinfo,
'smart': [],
'dmidecode': '',
'lspci': '',
},
}
body11, res = user.post(snapshot_11, res=Snapshot)
@ -1073,8 +1079,14 @@ def test_snapshot_errors(user: UserClient):
'wbid': 'MLKO1',
'software': 'Workbench',
'version': '2022.03.00',
"schema_version": "V1",
'data': {'lshw': lshw, 'hwinfo': hwinfo, 'smart': [], 'dmidecode': ''},
"schema_api": "1.0.0",
'data': {
'lshw': lshw,
'hwinfo': hwinfo,
'smart': [],
'dmidecode': '',
'lspci': '',
},
}
assert SnapshotErrors.query.all() == []