Skip to content

Commit

Permalink
Merge branch 'main' into issue-408
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma authored Jan 16, 2023
2 parents 55d0859 + a8c8c90 commit 5e6976b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import json

import yaml
import python_jsonschema_objects as pjs
from schema.helpers import pjs_filter
from ga4gh.gks.metaschema.tools.source_proc import YamlSchemaProcessor
from jsonschema import validate, RefResolver

from config import vrs_json_path, vrs_yaml_path
from config import vrs_json_path, vrs_yaml_path, root_dir

# Are the yaml and json parsable and do they match?
p = YamlSchemaProcessor(vrs_yaml_path)
Expand All @@ -19,3 +21,16 @@ def test_json_yaml_match():
def test_pjs_smoke():
ob = pjs.ObjectBuilder(pjs_filter(j))
assert ob.build_classes() # no exception => okay


def test_schema_validation():
"""Test that examples in validation/models.yaml are valid"""
resolver = RefResolver.from_schema(j, store={"definitions": j})
schema_definitions = j["definitions"]
validation_models = root_dir / "validation" / "models.yaml"
validation_tests = yaml.load(open(validation_models), Loader=yaml.SafeLoader)
for cls, tests in validation_tests.items():
for t in tests:
validate(instance=t["in"],
schema=schema_definitions[cls],
resolver=resolver)
4 changes: 4 additions & 0 deletions validation/models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ GenotypeMember:
start:
type: Number
value: 94761899
type: SequenceInterval
sequence_id: ga4gh:SQ.ss8r_wB0-b9r44TQTMmVTI92884QvBiB
type: SequenceLocation
state:
Expand All @@ -512,6 +513,7 @@ GenotypeMember:
start:
type: Number
value: 94842865
type: SequenceInterval
sequence_id: ga4gh:SQ.ss8r_wB0-b9r44TQTMmVTI92884QvBiB
type: SequenceLocation
state:
Expand Down Expand Up @@ -559,6 +561,7 @@ Genotype:
start:
type: Number
value: 94761899
type: SequenceInterval
sequence_id: ga4gh:SQ.ss8r_wB0-b9r44TQTMmVTI92884QvBiB
type: SequenceLocation
state:
Expand All @@ -573,6 +576,7 @@ Genotype:
start:
type: Number
value: 94842865
type: SequenceInterval
sequence_id: ga4gh:SQ.ss8r_wB0-b9r44TQTMmVTI92884QvBiB
type: SequenceLocation
state:
Expand Down

0 comments on commit 5e6976b

Please sign in to comment.