Skip to content

Commit e298bdc

Browse files
author
Peter Amstutz
committed
Detect when an abstract class is used but doesn't have a concrete subtype.
1 parent 851b3c1 commit e298bdc

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

schema_salad/schema.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ def extend_and_specialize(items, loader):
417417
add_dictlist(extended_by, ex, ex_types[t["name"]])
418418
add_dictlist(extended_by, avro_name(ex), ex_types[ex])
419419

420+
for t in n:
421+
if t.get("abstract") and t["name"] not in extended_by:
422+
raise validate.ValidationException("%s is abstract but missing a concrete subtype" % t["name"])
423+
420424
for t in n:
421425
if "fields" in t:
422426
t["fields"] = replace_type(t["fields"], extended_by, loader, set())

tests/test_examples.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ def test_schemas(self):
2020
"edam:has_format": "edam:format_1915"
2121
}, "")
2222

23-
self.assertEqual(ra, {
23+
self.assertEqual({
2424
"$schemas": ["tests/EDAM.owl"],
2525
"$namespaces": {"edam": "http://edamontology.org/"},
2626
'http://edamontology.org/has_format': 'http://edamontology.org/format_1915'
27-
})
27+
}, ra)
2828

2929
# def test_domain(self):
3030
# l = schema_salad.ref_resolver.Loader({})
@@ -46,9 +46,12 @@ def test_schemas(self):
4646
# })
4747

4848
def test_self_validate(self):
49-
schema_salad.main.main(argsl=["schema_salad/metaschema/metaschema.yml"])
50-
schema_salad.main.main(argsl=["schema_salad/metaschema/metaschema.yml",
51-
"schema_salad/metaschema/metaschema.yml"])
49+
self.assertEqual(0, schema_salad.main.main(argsl=["schema_salad/metaschema/metaschema.yml"]))
50+
self.assertEqual(0, schema_salad.main.main(argsl=["schema_salad/metaschema/metaschema.yml",
51+
"schema_salad/metaschema/metaschema.yml"]))
52+
53+
def test_avro_regression(self):
54+
self.assertEqual(0, schema_salad.main.main(argsl=["tests/Process.yml"]))
5255

5356
def test_jsonld_ctx(self):
5457
ldr, _, _, _ = schema_salad.schema.load_schema({

0 commit comments

Comments
 (0)