Merge pull request #419 from eReuse/feature/3999-setings

Feature/3999 fix setings_version and template
This commit is contained in:
cayop 2022-12-15 10:53:22 +01:00 committed by GitHub
commit 14b61cbaeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 4 deletions

View File

@ -90,7 +90,9 @@ class SnapshotsLog(Thing):
settings_version = self.snapshot.settings_version or '' settings_version = self.snapshot.settings_version or ''
settings_version = "".join([x[0] for x in settings_version.split(' ') if x]) settings_version = "".join([x[0] for x in settings_version.split(' ') if x])
if settings_version:
return "{} ({})".format(self.version, settings_version) return "{} ({})".format(self.version, settings_version)
return "{}".format(self.version)
class PlaceholdersLog(Thing): class PlaceholdersLog(Thing):

View File

@ -343,6 +343,7 @@ class ParseSnapshotLsHw:
"components": self.components, "components": self.components,
"uuid": snapshot['uuid'], "uuid": snapshot['uuid'],
"version": "14.0.0", "version": "14.0.0",
"settings_version": snapshot.get("settings_version"),
"endTime": snapshot["timestamp"], "endTime": snapshot["timestamp"],
"elapsed": 1, "elapsed": 1,
"sid": snapshot["sid"], "sid": snapshot["sid"],

View File

@ -22,6 +22,7 @@ class Snapshot_lite(Thing):
sid = String(required=True) sid = String(required=True)
type = String(required=True) type = String(required=True)
timestamp = String(required=True) timestamp = String(required=True)
settings_version = String(required=False)
data = Nested(Snapshot_lite_data, required=True) data = Nested(Snapshot_lite_data, required=True)
@validates_schema @validates_schema

View File

@ -14,7 +14,7 @@ WB_SMART_TEST = short
WB_ERASE = EraseBasic WB_ERASE = EraseBasic
WB_ERASE_STEPS = 1 WB_ERASE_STEPS = 1
WB_ERASE_LEADING_ZEROS = False WB_ERASE_LEADING_ZEROS = False
VERSION = "Basic Erasure (BE)" VERSION = Basic Erasure (BE)
{% elif baseline_erease %} {% elif baseline_erease %}
DH_HOST = {{ api_host }} DH_HOST = {{ api_host }}
@ -28,11 +28,11 @@ WB_SMART_TEST = short
WB_ERASE = EraseSectors WB_ERASE = EraseSectors
WB_ERASE_STEPS = {{ erase_steps }} WB_ERASE_STEPS = {{ erase_steps }}
WB_ERASE_LEADING_ZEROS = True WB_ERASE_LEADING_ZEROS = True
VERSION = {%if erase_steps < 3 %}"Baseline Secure Erasure (BSE)"{% else %}"Enhanced Secure Erasure (ESE)"{% endif %} VERSION = {%if erase_steps < 3 %}Baseline Secure Erasure (BSE){% else %}Enhanced Secure Erasure (ESE){% endif %}
{% else %} {% else %}
SNAPSHOTS_PATH = /mnt SNAPSHOTS_PATH = /mnt
LOGS_PATH = /mnt LOGS_PATH = /mnt
VERSION = "Basic Metadata (BM)" VERSION = Basic Metadata (BM)
{% endif %} {% endif %}

View File

@ -6,6 +6,7 @@
"software": "Workbench", "software": "Workbench",
"version": "2022.03.00", "version": "2022.03.00",
"schema_api": "1.0.0", "schema_api": "1.0.0",
"settings_version": "Basic Metadata",
"data": { "data": {
"lspci": "", "lspci": "",
"lshw": { "lshw": {

View File

@ -1413,3 +1413,18 @@ def test_bug_4028_components(user: UserClient):
for c in m.Device.query.filter(): for c in m.Device.query.filter():
assert c.binding or c.placeholder assert c.binding or c.placeholder
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_settings_version(user: UserClient):
"""Tests when we have one computer and then we change the disk, then
the new disk need to have placeholder too."""
s = file_json("2022-03-31_17h18m51s_ZQMPKKX51K67R68VO2X9RNZL08JPL_snapshot.json")
body, res = user.post(s, uri="/api/inventory/")
assert m.Computer.query.first().dhid == body['dhid']
snapshot = Snapshot.query.first()
log = SnapshotsLog.query.first()
assert log.get_version() == "14.0 (BM)"
assert snapshot.settings_version == "Basic Metadata"