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

Use utils in test

parent bebedffa
Branches
No related tags found
1 merge request!268Merge fork for interoperability of KoMa solver
...@@ -4,19 +4,16 @@ from collections import defaultdict ...@@ -4,19 +4,16 @@ from collections import defaultdict
from collections.abc import Iterable from collections.abc import Iterable
from datetime import datetime, timedelta from datetime import datetime, timedelta
from itertools import chain from itertools import chain
from pathlib import Path
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.test import TestCase from django.test import TestCase
from django.urls import reverse from django.urls import reverse
from jsonschema import Draft202012Validator
from jsonschema.exceptions import best_match from jsonschema.exceptions import best_match
from referencing import Registry, Resource
from AKModel.availability.models import Availability from AKModel.availability.models import Availability
from AKModel.models import AK, AKCategory, AKOwner, AKSlot, DefaultSlot, Event, Room from AKModel.models import AK, AKCategory, AKOwner, AKSlot, DefaultSlot, Event, Room
from AKPlanning import settings from AKModel.utils import construct_schema_validator
class JSONExportTest(TestCase): class JSONExportTest(TestCase):
...@@ -40,18 +37,7 @@ class JSONExportTest(TestCase): ...@@ -40,18 +37,7 @@ class JSONExportTest(TestCase):
is_active=True, is_active=True,
) )
schema_base_path = Path(settings.BASE_DIR) / "schemas" cls.json_export_validator = construct_schema_validator("solver-input.schema.json")
resources = []
for schema_path in schema_base_path.glob("**/*.schema.json"):
with schema_path.open("r") as ff:
res = Resource.from_contents(json.load(ff))
resources.append((res.id(), res))
registry = Registry().with_resources(resources)
with (schema_base_path / "solver-input.schema.json").open("r") as ff:
schema = json.load(ff)
cls.json_export_validator = Draft202012Validator(
schema=schema, registry=registry
)
def setUp(self): def setUp(self):
self.client.force_login(self.admin_user) self.client.force_login(self.admin_user)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment