Skip to content
Snippets Groups Projects
Commit b27360e3 authored by Felix Blanke's avatar Felix Blanke
Browse files

Format

parent 9bb08e85
No related branches found
No related tags found
1 merge request!25Feature: Use JSON schema
Pipeline #275667 passed
......@@ -37,7 +37,9 @@ class JSONExportTest(TestCase):
is_active=True,
)
cls.json_export_validator = construct_schema_validator("solver-input.schema.json")
cls.json_export_validator = construct_schema_validator(
"solver-input.schema.json"
)
def setUp(self):
self.client.force_login(self.admin_user)
......@@ -120,7 +122,9 @@ class JSONExportTest(TestCase):
with self.subTest(event=event):
self.set_up_event(event=event)
error = best_match(self.json_export_validator.iter_errors(self.export_dict))
error = best_match(
self.json_export_validator.iter_errors(self.export_dict)
)
msg = "" if error is None else error.message
self.assertTrue(error is None, msg)
......
......@@ -7,6 +7,7 @@ from referencing import Registry, Resource
from AKPlanning import settings
def construct_schema_validator(schema: str | dict) -> Validator:
"""Construct a validator for a JSON schema.
......@@ -23,6 +24,4 @@ def construct_schema_validator(schema: str | dict) -> Validator:
if isinstance(schema, str):
with (schema_base_path / schema).open("r") as ff:
schema = json.load(ff)
return Draft202012Validator(
schema=schema, registry=registry
)
return Draft202012Validator(schema=schema, registry=registry)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment