-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
74 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from pydantic import ValidationError | ||
import json | ||
|
||
from hdr_schemata.models.GWDM import Gwdm10 | ||
|
||
|
||
def get_metadata(model, version): | ||
metadata = json.load(open(f"../examples/{model}/{version}/example.json")) | ||
return metadata | ||
|
||
|
||
def get_schema(model, version): | ||
metadata = json.load(open(f"../models/{model}/{version}/schema.json")) | ||
return metadata | ||
|
||
|
||
class TestGwdm10: | ||
def __init__(self): | ||
self.metadata = get_metadata("GWDM", "1.0") | ||
self.json_schema = get_schema("GWDM", "1.0") | ||
|
||
def test_validation(self): | ||
assert Gwdm10(**self.metadata) != None | ||
|
||
def test_json_schema(self): | ||
schema = Gwdm10.model_json_schema() | ||
expected_keys = [ | ||
"$defs", | ||
"additionalProperties", | ||
"properties", | ||
"required", | ||
"title", | ||
"type", | ||
] | ||
|
||
assert list(schema.keys()) == expected_keys | ||
assert schema == self.json_schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from pydantic import ValidationError | ||
import json | ||
from hdr_schemata.models.HDRUK import Hdruk212 | ||
|
||
|
||
def get_metadata(model, version): | ||
metadata = json.load(open(f"../examples/{model}/{version}/example.json")) | ||
return metadata | ||
|
||
|
||
def get_schema(model, version): | ||
metadata = json.load(open(f"../models/{model}/{version}/schema.json")) | ||
return metadata | ||
|
||
|
||
class TestHdruk212: | ||
metadata = get_metadata("HDRUK", "2.1.2") | ||
json_schema = get_schema("HDRUK", "2.1.2") | ||
|
||
def test_validation(self): | ||
assert Hdruk212(**self.metadata) != None | ||
|
||
def test_json_schema(self): | ||
schema = Hdruk212.model_json_schema() | ||
expected_keys = [ | ||
"$defs", | ||
"additionalProperties", | ||
"properties", | ||
"required", | ||
"title", | ||
"type", | ||
] | ||
assert list(schema.keys()) == expected_keys | ||
assert schema == self.json_schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters