diff --git a/tests/unit/dataclasses/test_library.py b/tests/unit/dataclasses/test_library.py index cc84efde4..2be88c976 100644 --- a/tests/unit/dataclasses/test_library.py +++ b/tests/unit/dataclasses/test_library.py @@ -76,6 +76,17 @@ def test_load_library_from_ontology(bm: BuildingMOTIF): assert len(shapeg.graph) > 1 +def test_load_library_from_ontology_with_error(bm: BuildingMOTIF): + with pytest.raises(Exception): + Library.load(ontology_graph="tests/unit/fixtures/bad_shape_template.ttl") + + +def test_load_shapes_with_directory_library(bm: BuildingMOTIF): + lib = Library.load(directory="tests/unit/fixtures/shapes") + assert lib is not None + assert len(lib.get_templates()) == 1 + + def test_load_library_from_directory(bm: BuildingMOTIF): lib = Library.load(directory="tests/unit/fixtures/templates") assert lib is not None diff --git a/tests/unit/fixtures/bad_shape_template.ttl b/tests/unit/fixtures/bad_shape_template.ttl new file mode 100644 index 000000000..33d09dd6e --- /dev/null +++ b/tests/unit/fixtures/bad_shape_template.ttl @@ -0,0 +1,17 @@ +@prefix brick: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix sh: . +@prefix : . + +: a owl:Ontology . + +:vav_shape a sh:NodeShape ; + sh:targetClass brick:VAV ; + sh:property [ + sh:qualifiedValueShape [ sh:class brick:Air_Flow_Sensor ] ; + sh:qualifiedMinCount 1 ; + sh:minCount 1; + ] ; +. diff --git a/tests/unit/fixtures/shapes/shape1.ttl b/tests/unit/fixtures/shapes/shape1.ttl index d14097af9..8ec47229f 100644 --- a/tests/unit/fixtures/shapes/shape1.ttl +++ b/tests/unit/fixtures/shapes/shape1.ttl @@ -7,7 +7,7 @@ : a owl:Ontology . -:vav_shape a sh:NodeShape ; +:vav_shape a owl:Class, sh:NodeShape ; sh:targetClass brick:VAV ; sh:property [ sh:path brick:hasPoint ;