Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AKPlanning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Blanke
AKPlanning
Commits
ec606063
Commit
ec606063
authored
1 week ago
by
Felix Blanke
Browse files
Options
Downloads
Patches
Plain Diff
Setup validator
parent
0be02e48
No related branches found
Branches containing commit
No related tags found
1 merge request
!25
Feature: Use JSON schema
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AKModel/tests/test_json_export.py
+19
-10
19 additions, 10 deletions
AKModel/tests/test_json_export.py
with
19 additions
and
10 deletions
AKModel/tests/test_json_export.py
+
19
−
10
View file @
ec606063
import
json
import
math
from
collections
import
defaultdict
from
collections.abc
import
Iterable
from
datetime
import
datetime
,
timedelta
from
itertools
import
chain
from
pathlib
import
Path
from
bs4
import
BeautifulSoup
from
django.contrib.auth
import
get_user_model
from
django.test
import
TestCase
from
django.urls
import
reverse
from
jsonschema
import
Draft202012Validator
from
jsonschema.exceptions
import
best_match
from
referencing
import
Registry
,
Resource
from
AKModel.availability.models
import
Availability
from
AKModel.models
import
(
Event
,
AKOwner
,
AKCategory
,
AK
,
Room
,
AKSlot
,
DefaultSlot
,
)
from
AKModel.models
import
AK
,
AKCategory
,
AKOwner
,
AKSlot
,
DefaultSlot
,
Event
,
Room
from
AKPlanning
import
settings
class
JSONExportTest
(
TestCase
):
...
...
@@ -44,6 +40,19 @@ class JSONExportTest(TestCase):
is_active
=
True
,
)
schema_base_path
=
Path
(
settings
.
BASE_DIR
)
/
"
schemas
"
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.json
"
).
open
(
"
r
"
)
as
ff
:
schema
=
json
.
load
(
ff
)
cls
.
json_export_validator
=
Draft202012Validator
(
schema
=
schema
,
registry
=
registry
)
def
setUp
(
self
):
self
.
client
.
force_login
(
self
.
admin_user
)
self
.
export_dict
=
{}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment