Skip to content

Commit

Permalink
error messages simplified #81
Browse files Browse the repository at this point in the history
  • Loading branch information
hkir-dev committed Feb 25, 2022
1 parent c7aee9e commit aac5318
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dosdp/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_jschema(validator, pattern):
if not validator.is_valid(pattern):
es = validator.iter_errors(pattern)
for e in es:
warnings.warn(" => ".join([str(e.schema_path), str(e.message), str(e.context)]))
warnings.warn(str(e.message))
is_valid = False

return is_valid
Expand Down Expand Up @@ -262,7 +262,8 @@ def validate(pattern):

stat = True
for pattern_doc in pattern_docs:
logging.info("Checking %s" % pattern_doc)
if len(pattern_docs) > 1:
logging.info("Checking %s" % pattern_doc)
with open(pattern_doc, "r") as stream:
try:
pattern = ryaml.load(stream)
Expand Down
5 changes: 5 additions & 0 deletions src/schema/test/generic_test/validator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"../negative_test_set/multi_clause_with_multi_list2.yaml")
NEGATIVE_PATTERN_UNDECLARED_ANNOT_PROP = os.path.join(os.path.dirname(os.path.realpath(__file__)),
"../negative_test_set/undeclared_annotation_prop.yaml")
NEGATIVE_PATTERN_SCHEMA = os.path.join(os.path.dirname(os.path.realpath(__file__)),
"../negative_test_set/not_schema_compliant.yaml")


class ValidatorTest(unittest.TestCase):
Expand Down Expand Up @@ -65,3 +67,6 @@ def test_single_list_per_multi_clause(self):

def test_undeclared_annotation_prop(self):
self.assertFalse(validate(NEGATIVE_PATTERN_UNDECLARED_ANNOT_PROP))

def test_schema_validation(self):
self.assertFalse(validate(NEGATIVE_PATTERN_SCHEMA))
55 changes: 55 additions & 0 deletions src/schema/test/negative_test_set/not_schema_compliant.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
pattern_name: acute

pattern_iri: http://purl.obolibrary.org/obo/mondo/patterns/acute.yaml

description: 'This pattern is applied to diseases that are described as having an acute onset, i.e. the sudden appearance of disease manifestations over a short period of time.
Examples: [acute bronchiolitis](http://purl.obolibrary.org/obo/MONDO_0020680),
[acute liver failure](http://purl.obolibrary.org/obo/MONDO_0019542)'

contributors:
- https://orcid.org/0000-0002-6601-2165
- https://orcid.org/0000-0001-5208-3432

classes:
acute: PATO:0000389
disease: MONDO:0000001

relations:
has modifier: RO:0002573

annotationProperties:
exact_synonym: oio:hasExactSynonym
related_synonym: oio:hasRelatedSynonym

vars:
disease: '''disease'''

name:
text: acute %s
vars:
- disease

# axioms is not valid
axioms:
- annotationProperty: exact_synonym
text: '%s, acute'
vars:
- disease

annotations:
# property is not valid
- property: exact_synonym
text: '%s, acute'
vars:
- disease

def:
text: Acute form of %s.
vars:
- disease

equivalentTo:
text: '%s and ''has modifier'' some ''acute'''
vars:
- disease

0 comments on commit aac5318

Please sign in to comment.