-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add python variants to variant based tests (#2544)
This change adds python based variants to the variant tests. The python based variants provide a `populate_graph` function that populates a passed graph with quads or triples. This provides for the ability to do more nuanced and narrow tests using variants. Other changes: - Add some more variants for `diverse_quads` that explicitly sets the datatype of strings. - Removed the hand coded `simple_triple` graph from `test/data.py` as this is now subsumed by `test/data/variants/simple_triple.py`.
- Loading branch information
Showing
10 changed files
with
196 additions
and
33 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
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,73 @@ | ||
{ | ||
"@graph": [ | ||
{ | ||
"@graph": [ | ||
{ | ||
"@id": "egschema:subject", | ||
"egschema:predicate": [ | ||
12, | ||
{ | ||
"@id": "egschema:object" | ||
} | ||
] | ||
}, | ||
{ | ||
"@id": "eghttp:subject", | ||
"predicate": { | ||
"@language": "jpx", | ||
"@value": "日本語の表記体系" | ||
} | ||
}, | ||
{ | ||
"@id": "egurn:subject", | ||
"egschema:predicate": { | ||
"@id": "egschema:subject" | ||
} | ||
} | ||
], | ||
"@id": "egschema:graph" | ||
}, | ||
{ | ||
"@id": "egschema:subject", | ||
"egschema:predicate": { | ||
"@id": "egschema:object" | ||
} | ||
}, | ||
{ | ||
"@id": "eghttp:subject", | ||
"predicate": "typeless" | ||
}, | ||
{ | ||
"@graph": [ | ||
{ | ||
"@id": "egschema:subject", | ||
"egschema:predicate": { | ||
"@id": "egschema:object" | ||
}, | ||
"predicate": [ | ||
{"@value": "XSD string", "@type": "xsd:string"}, | ||
{ | ||
"@id": "eghttp:object" | ||
} | ||
] | ||
} | ||
], | ||
"@id": "egurn:graph" | ||
}, | ||
{ | ||
"@id": "egurn:subject", | ||
"egurn:predicate": { | ||
"@id": "egurn:object" | ||
} | ||
} | ||
], | ||
"@context": { | ||
"predicate": { | ||
"@id": "http://example.com/predicate" | ||
}, | ||
"egurn": "urn:example:", | ||
"xsd": "http://www.w3.org/2001/XMLSchema#", | ||
"egschema": "example:", | ||
"eghttp": "http://example.com/" | ||
} | ||
} |
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,10 @@ | ||
<http://example.com/subject> <http://example.com/predicate> "日本語の表記体系"@jpx <example:graph> . | ||
<urn:example:subject> <example:predicate> <example:subject> <example:graph> . | ||
<example:subject> <example:predicate> <example:object> <example:graph> . | ||
<example:subject> <example:predicate> "12"^^<http://www.w3.org/2001/XMLSchema#integer> <example:graph> . | ||
<example:subject> <example:predicate> <example:object> <urn:example:graph> . | ||
<example:subject> <http://example.com/predicate> <http://example.com/object> <urn:example:graph> . | ||
<example:subject> <http://example.com/predicate> "XSD string"^^<http://www.w3.org/2001/XMLSchema#string> <urn:example:graph> . | ||
<example:subject> <example:predicate> <example:object> . | ||
<http://example.com/subject> <http://example.com/predicate> "typeless" . | ||
<urn:example:subject> <urn:example:predicate> <urn:example:object> . |
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,29 @@ | ||
from test.utils.namespace import EGDC, EGSCHEME, EGURN | ||
|
||
from rdflib.graph import ConjunctiveGraph, Graph | ||
from rdflib.namespace import XSD | ||
from rdflib.term import Literal | ||
|
||
|
||
def populate_graph(graph: Graph) -> None: | ||
assert isinstance(graph, ConjunctiveGraph) | ||
|
||
graph.add((EGSCHEME.subject, EGSCHEME.predicate, EGSCHEME.object)) | ||
graph.add((EGDC.subject, EGDC.predicate, Literal("typeless"))) | ||
graph.add((EGURN.subject, EGURN.predicate, EGURN.object)) | ||
|
||
egscheme_graph = graph.get_context(EGSCHEME.graph) | ||
egscheme_graph.add((EGDC.subject, EGDC.predicate, Literal("日本語の表記体系", lang="jpx"))) | ||
egscheme_graph.add((EGURN.subject, EGSCHEME.predicate, EGSCHEME.subject)) | ||
egscheme_graph.add((EGSCHEME.subject, EGSCHEME.predicate, EGSCHEME.object)) | ||
egscheme_graph.add((EGSCHEME.subject, EGSCHEME.predicate, Literal(12))) | ||
|
||
egurn_graph = graph.get_context(EGURN.graph) | ||
egurn_graph.add((EGSCHEME.subject, EGSCHEME.predicate, EGSCHEME.object)) | ||
egurn_graph.add((EGSCHEME.subject, EGDC.predicate, EGDC.object)) | ||
egurn_graph.add( | ||
(EGSCHEME.subject, EGDC.predicate, Literal("XSD string", datatype=XSD.string)) | ||
) | ||
|
||
|
||
__all__ = ["populate_graph"] |
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,18 @@ | ||
from test.utils.namespace import EGDC, EGSCHEME, EGURN | ||
|
||
from rdflib.graph import Graph | ||
from rdflib.term import Literal | ||
|
||
|
||
def populate_graph(graph: Graph) -> None: | ||
assert isinstance(graph, Graph) | ||
|
||
graph.add((EGDC.subject, EGDC.predicate, Literal("日本語の表記体系", lang="jpx"))) | ||
graph.add((EGURN.subject, EGSCHEME.predicate, EGSCHEME.subject)) | ||
|
||
graph.add((EGSCHEME.object, EGDC.predicate, Literal("XSD string"))) | ||
graph.add((EGSCHEME.subject, EGSCHEME.predicate, EGSCHEME.object)) | ||
graph.add((EGSCHEME.subject, EGSCHEME.predicate, Literal(12))) | ||
|
||
|
||
__all__ = ["populate_graph"] |
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,13 @@ | ||
from test.utils.namespace import EGDO | ||
|
||
from rdflib.graph import ConjunctiveGraph, Graph | ||
|
||
|
||
def populate_graph(graph: Graph) -> None: | ||
assert isinstance(graph, ConjunctiveGraph) | ||
|
||
egdo_graph = graph.get_context(EGDO.graph) | ||
egdo_graph.add((EGDO.subject, EGDO.predicate, EGDO.object)) | ||
|
||
|
||
__all__ = ["populate_graph"] |
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,10 @@ | ||
from test.utils.namespace import EGDO | ||
|
||
from rdflib.graph import Graph | ||
|
||
|
||
def populate_graph(graph: Graph) -> None: | ||
graph.add((EGDO.subject, EGDO.predicate, EGDO.object)) | ||
|
||
|
||
__all__ = ["populate_graph"] |
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
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
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