Created
June 4, 2023 23:49
-
-
Save ashleysommer/0f5a0613e44bb06874cfae0e1e65c665 to your computer and use it in GitHub Desktop.
Pyshacl Test Issue 186
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
# -*- coding: utf-8 -*- | |
""" | |
https://github.com/RDFLib/pySHACL/issues/186 | |
""" | |
import rdflib | |
from pyshacl import validate | |
shacl_file = """{ | |
"@context": { | |
"sh": "http://www.w3.org/ns/shacl#", | |
"schema": "http://schema.org/", | |
"mud": "https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mud.ttl#" | |
}, | |
"@graph": [ | |
{ | |
"@id": "_:g0", | |
"sh:description": "Must have one species of vampire", | |
"sh:in": { | |
"@list": [ | |
{ | |
"@id": "https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mudfantasy.ttl#Vampire" | |
}, | |
"https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mudfantasy.ttl#Vampire" | |
] | |
}, | |
"sh:minCount": { | |
"@type": "http://www.w3.org/2001/XMLSchema#integer", | |
"@value": "1" | |
}, | |
"sh:name": "Species", | |
"sh:path": { | |
"@id": "mud:species" | |
} | |
}, | |
{ | |
"@id": "https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/shapes/mudfantasy/vampires.ttl#202304ParisVampire", | |
"@type": "sh:NodeShape", | |
"sh:property": { | |
"@id": "_:g0" | |
}, | |
"sh:targetClass": { | |
"@id": "https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mudchar.ttl#Character" | |
} | |
} | |
] | |
} | |
""" | |
data_file = """{ | |
"@context": { | |
"mud": "https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mud.ttl#", | |
"mudfantasy": "https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mudfantasy.ttl#" | |
}, | |
"@id": "https://example.com/John-Doe", | |
"@type": "https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mudchar.ttl#Character", | |
"mud:species": "Not a vampire" | |
} | |
""" | |
def test_186() -> None: | |
data_g = rdflib.Graph() | |
data_g.parse(data=data_file, format="json-ld") | |
shapes = rdflib.Graph() | |
shapes.parse(data=shacl_file, format="json-ld") | |
conforms, report, message = validate(data_g, shacl_graph=shapes, inference="none", debug=True) | |
assert not conforms | |
if __name__ == "__main__": | |
test_186() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment