-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(py-target): add test cases for custom Python-based targets
- Loading branch information
1 parent
d962cee
commit b65cf78
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# baseURI: http://datashapes.org/py/tests/target/pyTarget-001.test | ||
# imports: http://datashapes.org/dash | ||
# prefix: ex | ||
|
||
@prefix dash: <http://datashapes.org/dash#> . | ||
@prefix ex: <http://datashapes.org/py/tests/target/pyTarget-001.test#> . | ||
@prefix owl: <http://www.w3.org/2002/07/owl#> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
|
||
<http://datashapes.org/py/tests/target/pyTarget-001.test> | ||
rdf:type owl:Ontology ; | ||
rdfs:label "Test of sh:PyTarget 001" ; | ||
owl:imports <http://datashapes.org/dash> ; | ||
. | ||
ex:GraphValidationTestCase | ||
rdf:type dash:GraphValidationTestCase ; | ||
dash:expectedResult [ | ||
rdf:type sh:ValidationReport ; | ||
sh:conforms "false"^^xsd:boolean ; | ||
sh:result [ | ||
rdf:type sh:ValidationResult ; | ||
sh:focusNode ex:InvalidInstance1 ; | ||
sh:resultPath rdfs:label ; | ||
sh:resultSeverity sh:Violation ; | ||
sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; | ||
sh:sourceShape ex:TestShape-label ; | ||
] ; | ||
] ; | ||
. | ||
ex:InvalidInstance1 | ||
rdf:type owl:Thing ; | ||
rdfs:label "Invalid instance1" ; | ||
. | ||
ex:TestShape | ||
rdf:type sh:NodeShape ; | ||
rdfs:label "Test shape" ; | ||
sh:property ex:TestShape-label ; | ||
sh:target [ | ||
rdf:type sh:PyTarget ; | ||
sh:pyLibrary [ | ||
a sh:PyLibrary ; | ||
sh:pyLibraryURL "http://datashapes.org/py/tests/target/py_target-001.py"^^xsd:anyURI ; | ||
] ; | ||
sh:pyFunctionName "py_target001" ; | ||
] ; | ||
. | ||
ex:TestShape-label | ||
sh:path rdfs:label ; | ||
rdfs:comment "Must not have any rdfs:label" ; | ||
rdfs:label "label" ; | ||
sh:datatype xsd:string ; | ||
sh:maxCount 0 ; | ||
. | ||
ex:ValidInstance1 | ||
rdf:type owl:Thing ; | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
def py_target001(_this): | ||
target_nodes = [] | ||
rdf_type = py_tf.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type") | ||
owl_thing = py_tf.namedNode("http://www.w3.org/2002/07/owl#Thing") | ||
it = _data.find(_this, rdf_type, owl_thing) | ||
while t := it.next(): | ||
target_nodes.append(t.getSubject()) | ||
return target_nodes |