RDFLib / pySHACL

A Python validator for SHACL
Apache License 2.0
241 stars 63 forks source link

Add test for sh:inversePath #161

Closed ajnelson-nist closed 1 year ago

ajnelson-nist commented 1 year ago

The initial patch of this PR will fail CI, because the implemented test does not have an expected conformance result presently.

ashleysommer commented 1 year ago

Following on from my comment in #160, changing your targeting method from targetSubjectsOf to targetObjectsOf allows the sh:inversePath pathing route to work as expected (because inversePath goes object -> path -> subject). However this test is still failing because using targetObjectsOf causes the focusNode and valueNode to switch around causing the second assertion to fail. This is the output:

Constraint Violation in ClassConstraintComponent (http://www.w3.org/ns/shacl#ClassConstraintComponent):
    Severity: sh:Violation
    Source Shape: ex:propertyOfA-shape
    Focus Node: Literal("1")
    Value Node: kb:thing-b-1
    Result Path: [ sh:inversePath ex:propertyOfA ]
    Message: Value does not have class ex:ThingA

So line 78 needs to be changed to check for the expected URI in valueNode rather than focusNode.