Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add more graph variants highlighting bugs #1895

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/data/variants/diverse_quads-asserts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"quad_count": 10,
"exact_match": true
}
73 changes: 73 additions & 0 deletions test/data/variants/diverse_quads.jsonld
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": [
"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/"
}
}
10 changes: 10 additions & 0 deletions test/data/variants/diverse_quads.nq
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" <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> .
27 changes: 27 additions & 0 deletions test/data/variants/diverse_quads.trig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@prefix egschema: <example:> .
@prefix eghttp: <http://example.com/> .
@prefix egurn: <urn:example:> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

egschema:graph {
eghttp:subject eghttp:predicate "日本語の表記体系"@jpx .

egurn:subject egschema:predicate egschema:subject .

egschema:subject egschema:predicate egschema:object,
12 .
}

egurn:graph {
egschema:subject egschema:predicate egschema:object ;
eghttp:predicate eghttp:object,
"XSD string"^^xsd:string .
}

{
egschema:subject egschema:predicate egschema:object .

eghttp:subject eghttp:predicate "typeless" .

egurn:subject egurn:predicate egurn:object .
}
4 changes: 4 additions & 0 deletions test/data/variants/diverse_triples-asserts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"quad_count": 5,
"exact_match": true
}
5 changes: 5 additions & 0 deletions test/data/variants/diverse_triples.hext
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
["urn:example:subject", "example:predicate", "example:subject", "globalId", "", ""]
["example:subject", "example:predicate", "example:object", "globalId", "", ""]
["example:object", "http://example.com/predicate", "XSD string", "http://www.w3.org/2001/XMLSchema#string", "", ""]
["http://example.com/subject", "http://example.com/predicate", "日本語の表記体系", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString", "jpx", ""]
["example:subject", "example:predicate", "12", "http://www.w3.org/2001/XMLSchema#integer", "", ""]
40 changes: 40 additions & 0 deletions test/data/variants/diverse_triples.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"@graph": [
{
"@id": "egschema:object",
"eghttp:predicate": "XSD string"
},
{
"@id": "egschema:subject",
"egschema:predicate": [
12,
{
"@id": "egschema:object"
}
]
},
{
"@id": "eghttp:subject",
"eghttp:predicate": {
"@language": "jpx",
"@value": "日本語の表記体系"
}
},
{
"@id": "egurn:subject",
"egschema:predicate": {
"@id": "egschema:subject"
}
}
],
"@context": {
"predicate": {
"@id": "example:predicate",
"@type": "http://www.w3.org/2001/XMLSchema#integer"
},
"egurn": "urn:example:",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"egschema": "example:",
"eghttp": "http://example.com/"
}
}
5 changes: 5 additions & 0 deletions test/data/variants/diverse_triples.nt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<http://example.com/subject> <http://example.com/predicate> "日本語の表記体系"@jpx .
<urn:example:subject> <example:predicate> <example:subject> .
<example:object> <http://example.com/predicate> "XSD string" .
<example:subject> <example:predicate> <example:object> .
<example:subject> <example:predicate> "12"^^<http://www.w3.org/2001/XMLSchema#integer> .
13 changes: 13 additions & 0 deletions test/data/variants/diverse_triples.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@prefix eghttp: <http://example.com/> .
@prefix egurn: <urn:example:> .
@prefix egschema: <example:> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

eghttp:subject eghttp:predicate "日本語の表記体系"@jpx .

egurn:subject egschema:predicate egschema:subject .

egschema:object eghttp:predicate "XSD string"^^xsd:string .

egschema:subject egschema:predicate egschema:object,
12 .
4 changes: 4 additions & 0 deletions test/data/variants/more_quads-asserts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"quad_count": 6,
"exact_match": true
}
56 changes: 56 additions & 0 deletions test/data/variants/more_quads.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"@graph": [
{
"@graph": [
{
"@id": "example:s20",
"example:p20": {
"@id": "example:o20"
}
},
{
"@id": "example:s21",
"example:p21": {
"@id": "example:o21"
}
}
],
"@id": "example:g2"
},
{
"@id": "example:s00",
"p00": "example:o02"
},
{
"@id": "example:s01",
"p01": "example:o01"
},
{
"@id": "example:s10",
"p10": "example:o10"
},
{
"@id": "example:s11",
"p11": "example:o11"
}
],
"@context": {
"p10": {
"@id": "http://example.org/p10",
"@type": "@id"
},
"p01": {
"@id": "http://example.org/p01",
"@type": "@id"
},
"p00": {
"@id": "http://example.org/p00",
"@type": "@id"
},
"p11": {
"@id": "http://example.org/p11",
"@type": "@id"
},
"example": "http://example.org/"
}
}
6 changes: 6 additions & 0 deletions test/data/variants/more_quads.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<http://example.org/s00> <http://example.org/p00> <http://example.org/o02> .
<http://example.org/s01> <http://example.org/p01> <http://example.org/o01> .
<http://example.org/s10> <http://example.org/p10> <http://example.org/o10> .
<http://example.org/s11> <http://example.org/p11> <http://example.org/o11> .
<http://example.org/s20> <http://example.org/p20> <http://example.org/o20> <http://example.org/g2> .
<http://example.org/s21> <http://example.org/p21> <http://example.org/o21> <http://example.org/g2> .
15 changes: 15 additions & 0 deletions test/data/variants/more_quads.trig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@prefix example: <http://example.org/>.

example:s00 example:p00 example:o02 .
example:s01 example:p01 example:o01 .


{
example:s10 example:p10 example:o10 .
example:s11 example:p11 example:o11 .
}

example:g2 {
example:s20 example:p20 example:o20 .
example:s21 example:p21 example:o21 .
}
23 changes: 23 additions & 0 deletions test/test_graph/test_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import os
import re
import sys
from dataclasses import dataclass, field
from pathlib import Path, PurePath
from test.data import TEST_DATA_DIR
Expand Down Expand Up @@ -165,8 +166,30 @@ def for_directory(
""",
raises=AssertionError,
),
("variants/diverse_quads"): pytest.mark.xfail(
reason="""
TriG parsing gets confused about what graph 'XSD string' appears in:
(rdflib.term.URIRef('example:subject'),
rdflib.term.URIRef('http://example.com/predicate'),
rdflib.term.Literal('XSD string'),
- rdflib.term.URIRef('example:graph')),
+ rdflib.term.URIRef('urn:example:graph')),
? ++++
""",
raises=AssertionError,
),
}

if sys.platform == "win32":
EXPECTED_FAILURES["variants/diverse_triples"] = pytest.mark.xfail(
reason="""
Some encoding issue when parsing hext on windows:
> return codecs.charmap_decode(input,self.errors,decoding_table)[0]
E UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 356: character maps to <undefined>
""",
raises=UnicodeDecodeError,
)


def tests_found() -> None:
logging.debug("VARIANTS_DIR = %s", VARIANTS_DIR)
Expand Down
23 changes: 23 additions & 0 deletions test/test_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,26 @@
""",
raises=AssertionError,
),
("json-ld", "diverse_quads.trig"): pytest.mark.xfail(
reason="""
jsonld serializer is dropping datatype:
only in first:
(rdflib.term.URIRef('example:subject'), rdflib.term.URIRef('http://example.com/predicate'), rdflib.term.Literal('XSD string', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#string')))
only in second:
(rdflib.term.URIRef('example:subject'), rdflib.term.URIRef('http://example.com/predicate'), rdflib.term.Literal('XSD string'))
""",
raises=AssertionError,
),
("hext", "diverse_quads.trig"): pytest.mark.xfail(
reason="""
hext serializer is dropping datatype:
only in first:
(rdflib.term.URIRef('example:subject'), rdflib.term.URIRef('http://example.com/predicate'), rdflib.term.Literal('XSD string', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#string')))
only in second:
(rdflib.term.URIRef('example:subject'), rdflib.term.URIRef('http://example.com/predicate'), rdflib.term.Literal('XSD string'))
""",
raises=AssertionError,
),
}

# This is for files which can only be represented properly in one format
Expand Down Expand Up @@ -291,6 +311,9 @@ def test_n3(checker: Callable[[str, str, Path], None], args: Tuple[str, str, Pat
(TEST_DATA_DIR / "variants" / "rdf_prefix.jsonld", "json-ld"),
(TEST_DATA_DIR / "variants" / "simple_quad.trig", "trig"),
(TEST_DATA_DIR / "variants" / "rdf11trig_eg2.trig", "trig"),
(TEST_DATA_DIR / "variants" / "diverse_triples.nt", "ntriples"),
(TEST_DATA_DIR / "variants" / "diverse_quads.nq", "nquads"),
(TEST_DATA_DIR / "variants" / "diverse_quads.trig", "trig"),
(TEST_DATA_DIR / "example-lots_of_graphs.n3", "n3"),
(TEST_DATA_DIR / "issue156.n3", "n3"),
]
Expand Down