|
8 | 8 |
|
9 | 9 | from buildingmotif.dataclasses.library import Library |
10 | 10 | from buildingmotif.dataclasses.shape_collection import ShapeCollection |
11 | | -from buildingmotif.namespaces import BMOTIF, BRICK |
| 11 | +from buildingmotif.namespaces import BMOTIF, BRICK, PARAM |
12 | 12 |
|
13 | 13 |
|
14 | 14 | def test_create_shape_collection(clean_building_motif): |
@@ -185,3 +185,44 @@ def test_shape_to_query(clean_building_motif, shape_name, query_clauses): |
185 | 185 | assert clause in query, query |
186 | 186 | # Validate that the query executes correctly |
187 | 187 | g.query(query) |
| 188 | + |
| 189 | + |
| 190 | +def test_infer_templates_accepts_rdfs_class(clean_building_motif): |
| 191 | + graph = Graph() |
| 192 | + graph.parse( |
| 193 | + data=""" |
| 194 | + @prefix : <urn:test#> . |
| 195 | + @prefix owl: <http://www.w3.org/2002/07/owl#> . |
| 196 | + @prefix sh: <http://www.w3.org/ns/shacl#> . |
| 197 | + @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
| 198 | + @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . |
| 199 | +
|
| 200 | + :ontology a owl:Ontology . |
| 201 | +
|
| 202 | + :MyShape a sh:NodeShape, rdfs:Class ; |
| 203 | + sh:targetClass :MyShape ; |
| 204 | + sh:property [ |
| 205 | + sh:path :hasChild ; |
| 206 | + sh:minCount 1 ; |
| 207 | + sh:name "child" ; |
| 208 | + sh:class :ChildClass ; |
| 209 | + ] . |
| 210 | +
|
| 211 | + :ChildShape a sh:NodeShape, rdfs:Class ; |
| 212 | + sh:targetClass :ChildClass ; |
| 213 | + sh:property [ |
| 214 | + sh:path :label ; |
| 215 | + sh:minCount 1 ; |
| 216 | + sh:datatype xsd:string ; |
| 217 | + ] . |
| 218 | +
|
| 219 | + :ChildClass a rdfs:Class . |
| 220 | + """, |
| 221 | + format="turtle", |
| 222 | + ) |
| 223 | + |
| 224 | + lib = Library.load( |
| 225 | + ontology_graph=graph, infer_templates=True, run_shacl_inference=False |
| 226 | + ) |
| 227 | + template = lib.get_template_by_name("urn:test#MyShape") |
| 228 | + assert (PARAM["name"], RDF.type, URIRef("urn:test#MyShape")) in template.body |
0 commit comments