Skip to content

Commit

Permalink
Bump schema number to 1.1 and use it in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Waltlova <[email protected]>
  • Loading branch information
andywaltlova committed Nov 9, 2023
1 parent 6ba419b commit 36dd9ea
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 6 deletions.
4 changes: 0 additions & 4 deletions schemas/preconversion_assessment_schema_1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
"status": {
"$ref": "#/$defs/status_codes"
},
"alert": {
"type": "boolean"
},
"report": {
"type": "string"
},
Expand Down Expand Up @@ -44,7 +41,6 @@
},
"required": [
"status",
"alert",
"message",
"report",
"report_json"
Expand Down
68 changes: 68 additions & 0 deletions schemas/preconversion_assessment_schema_1.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"title": "Convert2rhel pre-conversion script schema",
"description": "Script is expected to set up Convert2rhel and run pre-conversion assessment. This schema defines the output format that is expected by Red Hat Insights Task UI.",
"type": "object",
"properties": {
"status": {
"$ref": "#/$defs/status_codes"
},
"alert": {
"type": "boolean"
},
"report": {
"type": "string"
},
"message": {
"type": "string"
},
"report_json": {
"oneOf": [
{
"type": "null"
},
{
"type": "object",
"properties": {
"entries": {
"type": "object"
},
"tasks_format_version": {
"type": "string"
},
"tasks_format_id": {
"type": "string"
}
},
"required": [
"entries",
"tasks_format_version",
"tasks_format_id"
]
}
]
}
},
"required": [
"status",
"alert",
"message",
"report",
"report_json"
],
"additionalProperties": false,
"$defs": {
"status_codes": {
"description": "The severity of the results and messages",
"type": "string",
"enum": [
"SUCCESS",
"INFO",
"WARNING",
"SKIP",
"OVERRIDABLE",
"ERROR"
]
}
}
}

4 changes: 2 additions & 2 deletions tests/preconversion_assessment/test_output_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_output_schema():
output_collector = OutputCollector(status=status)
empty_output = output_collector.to_dict()

with open("schemas/preconversion_assessment_schema_1.0.json", "r") as schema:
with open("schemas/preconversion_assessment_schema_1.1.json", "r") as schema:
schema_json = json.load(schema)
# If some difference between generated json and its schema invoke exception
jsonschema.validate(instance=empty_output, schema=schema_json)
Expand All @@ -27,7 +27,7 @@ def test_output_schema_entries_report():
output_collector.entries = {"hi": "world"}
full_output = output_collector.to_dict()

with open("schemas/preconversion_assessment_schema_1.0.json", "r") as schema:
with open("schemas/preconversion_assessment_schema_1.1.json", "r") as schema:
schema_json = json.load(schema)
# If some difference between generated json and its schema invoke exception
jsonschema.validate(instance=full_output, schema=schema_json)

0 comments on commit 36dd9ea

Please sign in to comment.