Skip to content

Commit

Permalink
test(py-rdfquery): add paths tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleycaselli committed Jan 25, 2024
1 parent bf8241e commit b5e45d9
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/test/resources/py/tests-rdfquery/paths.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,38 @@
def inverse_path_single():
return rdf_query(_data).path("sh:Shape", {"inverse": T("rdfs:subClassOf")}, "?subClass").get_count()


def one_or_more():
return rdf_query(_data).path(py_tf.namedNode("http://datashapes.org/js/tests-rdfquery/paths.test#MergedClass"),
{"oneOrMore": T("rdfs:subClassOf")}, "?superClass").get_count()


def or_path_label_or_comment():
return rdf_query(_data).path("sh:Shape", {"or": [T("rdfs:label"), T("rdfs:comment")]}, "?text").get_count()


def predicate_path_single():
return rdf_query(_data).path("sh:Shape", "rdfs:label", "?label").get_node("?label")


def predicate_path_chain():
return rdf_query(_data).path("sh:PropertyShape", "rdfs:subClassOf", "?Shape").path("?Shape", "rdfs:label",
"?label").get_node("?label")


def sequence_path_2():
return rdf_query(_data).path("owl:Thing", [T("rdf:type"), T("rdfs:subClassOf")], "?Class").get_node("?Class")


def sequence_path_3():
return rdf_query(_data).path("owl:Thing", [T("rdf:type"), T("rdfs:subClassOf"), T("rdf:type")], "?type").get_node(
"?type")


def zero_or_one():
return rdf_query(_data).path("owl:Thing", {"zeroOrOne": T("rdf:type")}, "?type").get_count()


def zero_or_more():
return rdf_query(_data).path(py_tf.namedNode("http://datashapes.org/js/tests-rdfquery/paths.test#MergedClass"),
{"zeroOrMore": T("rdfs:subClassOf")}, "?superClass").get_count()
81 changes: 81 additions & 0 deletions src/test/resources/py/tests-rdfquery/paths.test.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,96 @@
owl:imports <http://datashapes.org/dash> ;
owl:versionInfo "Created with TopBraid Composer" ;
.
ex:MergedClass
rdf:type rdfs:Class ;
rdfs:label "Merged class" ;
rdfs:subClassOf ex:MiddleClass1 ;
rdfs:subClassOf ex:MiddleClass2 ;
.
ex:MiddleClass1
rdf:type rdfs:Class ;
rdfs:label "Middle class1" ;
rdfs:subClassOf ex:RootClass ;
rdfs:subClassOf ex:SiblingClass ;
.
ex:MiddleClass2
rdf:type rdfs:Class ;
rdfs:label "Middle class2" ;
rdfs:subClassOf ex:RootClass ;
.
ex:RootClass
rdf:type rdfs:Class ;
rdfs:label "Root class" ;
rdfs:subClassOf rdfs:Resource ;
.
ex:SiblingClass
rdf:type rdfs:Class ;
rdfs:label "Sibling class" ;
rdfs:subClassOf rdfs:Resource ;
.
ex:inversePathSingle
rdf:type dash:PyTestCase ;
dash:expectedResult 2 ;
rdfs:label "inverse path single" ;
sh:pyFunctionName "inverse_path_single" ;
sh:pyLibrary <http://datashapes.org/py/tests-rdfquery/paths.test#paths.py> ;
.
ex:oneOrMore
rdf:type dash:PyTestCase ;
dash:expectedResult 5 ;
rdfs:label "one or more" ;
sh:pyFunctionName "one_or_more" ;
sh:pyLibrary <http://datashapes.org/py/tests-rdfquery/paths.test#paths.py> ;
.
ex:orPathLabelOrComment
rdf:type dash:PyTestCase ;
dash:expectedResult 2 ;
rdfs:label "or path label or comment" ;
sh:pyFunctionName "or_path_label_or_comment" ;
sh:pyLibrary <http://datashapes.org/py/tests-rdfquery/paths.test#paths.py> ;
.
<http://datashapes.org/py/tests-rdfquery/paths.test#paths.py>
rdf:type sh:PyLibrary ;
sh:pyLibrary dash:RDFQueryPyLibrary ;
sh:pyLibraryURL "http://datashapes.org/py/tests-rdfquery/paths.py"^^xsd:anyURI ;
.
ex:predicatePathChain
rdf:type dash:PyTestCase ;
dash:expectedResult "Shape"@en ;
sh:pyFunctionName "predicate_path_chain" ;
sh:pyLibrary <http://datashapes.org/py/tests-rdfquery/paths.test#paths.py> ;
.
ex:predicatePathSingle
rdf:type dash:PyTestCase ;
dash:expectedResult "Shape"@en ;
rdfs:label "predicate path single" ;
sh:pyFunctionName "predicate_path_single" ;
sh:pyLibrary <http://datashapes.org/py/tests-rdfquery/paths.test#paths.py> ;
.
ex:sequencePath2
rdf:type dash:PyTestCase ;
dash:expectedResult rdfs:Class ;
rdfs:label "sequence path2" ;
sh:pyFunctionName "sequence_path_2" ;
sh:pyLibrary <http://datashapes.org/py/tests-rdfquery/paths.test#paths.py> ;
.
ex:sequencePath3
rdf:type dash:PyTestCase ;
dash:expectedResult rdfs:Class ;
rdfs:label "sequence path3" ;
sh:pyFunctionName "sequence_path_3" ;
sh:pyLibrary <http://datashapes.org/py/tests-rdfquery/paths.test#paths.py> ;
.
ex:zeroOrMore
rdf:type dash:PyTestCase ;
dash:expectedResult 6 ;
rdfs:label "zero or more" ;
sh:pyFunctionName "zero_or_more" ;
sh:pyLibrary <http://datashapes.org/py/tests-rdfquery/paths.test#paths.py> ;
.
ex:zeroOrOne
rdf:type dash:PyTestCase ;
dash:expectedResult 2 ;
sh:pyFunctionName "zero_or_one" ;
sh:pyLibrary <http://datashapes.org/py/tests-rdfquery/paths.test#paths.py> ;
.

0 comments on commit b5e45d9

Please sign in to comment.