Skip to content

Commit

Permalink
Break out schema check
Browse files Browse the repository at this point in the history
  • Loading branch information
e-backmark-ericsson committed Jan 11, 2024
1 parent 53f45ad commit 6530994
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test_jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import pytest

# Set up a console logger
logger = logging.getLogger("__Logger__")
logger = logging.getLogger("__name__")
console_handler = logging.StreamHandler()
formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s",
Expand All @@ -39,19 +39,22 @@
)
def test_json_schema(filename):
with open(filename) as input_file:
event_schema = json.loads(input_file.read())
event_schema = json.load(input_file)

# Use standard validator for old ActC schemas, to cope with bug https://github.com/eiffel-community/eiffel/issues/376
# Evaluate which schema validator to use. Use standard validator for old ActC
# schemas, to cope with bug https://github.com/eiffel-community/eiffel/issues/376
schema_validator = None
if ("ActivityCanceled" in filename) and (
event_schema["properties"]["meta"]["properties"]["version"]["default"]
in ["1.0.0", "1.1.0", "2.0.0", "3.0.0", "3.1.0", "3.2.0"]
):
jsonschema.Draft4Validator.check_schema(event_schema)
schema_validator = jsonschema.Draft4Validator
else:
stricter_metaschema = dict(
jsonschema.Draft4Validator.META_SCHEMA, additionalProperties=False
)
StrictDraft4Validator = jsonschema.validators.create(
schema_validator = jsonschema.validators.create(
stricter_metaschema, jsonschema.Draft4Validator.VALIDATORS, "StrictDraft4"
)
StrictDraft4Validator.check_schema(event_schema)

schema_validator.check_schema(event_schema)

0 comments on commit 6530994

Please sign in to comment.