Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
aucampia committed Jun 5, 2022
1 parent e677274 commit 2f9f586
Show file tree
Hide file tree
Showing 81 changed files with 20,793 additions and 5,834 deletions.
2 changes: 2 additions & 0 deletions rdflib/plugins/sparql/results/csvresults.py
Expand Up @@ -83,5 +83,7 @@ def serialize(self, stream: IO, encoding: str = "utf-8", **kwargs):
def serializeTerm(self, term, encoding):
if term is None:
return ""
elif isinstance(term, BNode):
return f"_:{term}"
else:
return term
62 changes: 5 additions & 57 deletions test/README.rst
Expand Up @@ -46,60 +46,8 @@ test_conneg - test content negotiation when reading remote graphs
EARL Test Reports
=================

EARL test reports can be generated using the EARL reporter plugin from ``earl.py``.

When this plugin is enabled it will create an ``earl:Assertion`` for every test that has a ``rdf_test_uri`` parameter which can be either a string or an ``URIRef``.

To enable the EARL reporter plugin an output file path must be supplied to pytest with ``--earl-report``. The report will be written to this location in turtle format.

Some examples of generating test reports:

.. code-block:: bash
pytest \
--earl-asserter-homepage=http://example.com \
--earl-asserter-name 'Example Name' \
--earl-report=/var/tmp/earl/earl-jsonld-local.ttl \
test/jsonld/test_localsuite.py
pytest \
--earl-asserter-homepage=http://example.com \
--earl-asserter-name 'Example Name' \
--earl-report=/var/tmp/earl/earl-jsonld-v1.1.ttl \
test/jsonld/test_onedotone.py
pytest \
--earl-asserter-homepage=http://example.com \
--earl-asserter-name 'Example Name' \
--earl-report=/var/tmp/earl/earl-jsonld-v1.0.ttl \
test/jsonld/test_testsuite.py
pytest \
--earl-asserter-homepage=http://example.com \
--earl-asserter-name 'Example Name' \
--earl-report=/var/tmp/earl/earl-sparql.ttl \
test/test_dawg.py
pytest \
--earl-asserter-homepage=http://example.com \
--earl-asserter-name 'Example Name' \
--earl-report=/var/tmp/earl/earl-nquads.ttl \
test/test_nquads_w3c.py
pytest \
--earl-asserter-homepage=http://example.com \
--earl-asserter-name 'Example Name' \
--earl-report=/var/tmp/earl/earl-nt.ttl \
test/test_nt_w3c.py
pytest \
--earl-asserter-uri=http://example.com \
--earl-asserter-name 'Example Name' \
--earl-report=/var/tmp/earl/earl-trig.ttl \
test/test_trig_w3c.py
pytest \
--earl-asserter-uri=http://example.com \
--earl-asserter-name 'Example Name' \
--earl-report=/var/tmp/earl/earl-turtle.ttl \
test/test_turtle_w3c.py
EARL test reports are generated using the EARL reporter plugin from ``test/utils/earl.py``.

This plugin is enabled by default and writes test reports to ``test_reports/*-latest.ttl`` by default.

For plugin options see the output of ``pytest --help``.
4 changes: 2 additions & 2 deletions test/conftest.py
Expand Up @@ -5,9 +5,9 @@
from rdflib import Graph

from .data import TEST_DATA_DIR
from .utils.earl import EarlReporter
from .utils.earl import EARLReporter # noqa: E402

pytest_plugins = [EarlReporter.__module__]
pytest_plugins = [EARLReporter.__module__]

# This is here so that asserts from these modules are formatted for human
# readibility.
Expand Down
154 changes: 154 additions & 0 deletions test/data/defined_namespaces/rdf.ttl
@@ -0,0 +1,154 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .

<http://www.w3.org/1999/02/22-rdf-syntax-ns#> a owl:Ontology ;
dc:title "The RDF Concepts Vocabulary (RDF)" ;
dc:date "2019-12-16" ;
dc:description "This is the RDF Schema for the RDF vocabulary terms in the RDF Namespace, defined in RDF 1.1 Concepts." .

rdf:HTML a rdfs:Datatype ;
rdfs:subClassOf rdfs:Literal ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:seeAlso <http://www.w3.org/TR/rdf11-concepts/#section-html> ;
rdfs:label "HTML" ;
rdfs:comment "The datatype of RDF literals storing fragments of HTML content" .

rdf:langString a rdfs:Datatype ;
rdfs:subClassOf rdfs:Literal ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:seeAlso <http://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal> ;
rdfs:label "langString" ;
rdfs:comment "The datatype of language-tagged string values" .

rdf:PlainLiteral a rdfs:Datatype ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:subClassOf rdfs:Literal ;
rdfs:seeAlso <http://www.w3.org/TR/rdf-plain-literal/> ;
rdfs:label "PlainLiteral" ;
rdfs:comment "The class of plain (i.e. untyped) literal values, as used in RIF and OWL 2" .

rdf:type a rdf:Property ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "type" ;
rdfs:comment "The subject is an instance of a class." ;
rdfs:range rdfs:Class ;
rdfs:domain rdfs:Resource .

rdf:Property a rdfs:Class ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "Property" ;
rdfs:comment "The class of RDF properties." ;
rdfs:subClassOf rdfs:Resource .

rdf:Statement a rdfs:Class ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "Statement" ;
rdfs:subClassOf rdfs:Resource ;
rdfs:comment "The class of RDF statements." .

rdf:subject a rdf:Property ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "subject" ;
rdfs:comment "The subject of the subject RDF statement." ;
rdfs:domain rdf:Statement ;
rdfs:range rdfs:Resource .

rdf:predicate a rdf:Property ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "predicate" ;
rdfs:comment "The predicate of the subject RDF statement." ;
rdfs:domain rdf:Statement ;
rdfs:range rdfs:Resource .

rdf:object a rdf:Property ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "object" ;
rdfs:comment "The object of the subject RDF statement." ;
rdfs:domain rdf:Statement ;
rdfs:range rdfs:Resource .

rdf:Bag a rdfs:Class ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "Bag" ;
rdfs:comment "The class of unordered containers." ;
rdfs:subClassOf rdfs:Container .

rdf:Seq a rdfs:Class ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "Seq" ;
rdfs:comment "The class of ordered containers." ;
rdfs:subClassOf rdfs:Container .

rdf:Alt a rdfs:Class ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "Alt" ;
rdfs:comment "The class of containers of alternatives." ;
rdfs:subClassOf rdfs:Container .

rdf:value a rdf:Property ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "value" ;
rdfs:comment "Idiomatic property used for structured values." ;
rdfs:domain rdfs:Resource ;
rdfs:range rdfs:Resource .

rdf:List a rdfs:Class ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "List" ;
rdfs:comment "The class of RDF Lists." ;
rdfs:subClassOf rdfs:Resource .

rdf:nil a rdf:List ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "nil" ;
rdfs:comment "The empty list, with no items in it. If the rest of a list is nil then the list has no more items in it." .

rdf:first a rdf:Property ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "first" ;
rdfs:comment "The first item in the subject RDF list." ;
rdfs:domain rdf:List ;
rdfs:range rdfs:Resource .

rdf:rest a rdf:Property ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "rest" ;
rdfs:comment "The rest of the subject RDF list after the first item." ;
rdfs:domain rdf:List ;
rdfs:range rdf:List .

rdf:XMLLiteral a rdfs:Datatype ;
rdfs:subClassOf rdfs:Literal ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:label "XMLLiteral" ;
rdfs:comment "The datatype of XML literal values." .

rdf:JSON a rdfs:Datatype ;
rdfs:label "JSON" ;
rdfs:comment "The datatype of RDF literals storing JSON content." ;
rdfs:subClassOf rdfs:Literal ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:seeAlso <https://www.w3.org/TR/json-ld11/#the-rdf-json-datatype> .

rdf:CompoundLiteral a rdfs:Class ;
rdfs:label "CompoundLiteral" ;
rdfs:comment "A class representing a compound literal." ;
rdfs:subClassOf rdfs:Resource ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:seeAlso <https://www.w3.org/TR/json-ld11/#the-rdf-compoundliteral-class-and-the-rdf-language-and-rdf-direction-properties> .

rdf:language a rdf:Property ;
rdfs:label "language" ;
rdfs:comment "The language component of a CompoundLiteral." ;
rdfs:domain rdf:CompoundLiteral ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:seeAlso <https://www.w3.org/TR/json-ld11/#the-rdf-compoundliteral-class-and-the-rdf-language-and-rdf-direction-properties> .

rdf:direction a rdf:Property ;
rdfs:label "direction" ;
rdfs:comment "The base direction component of a CompoundLiteral." ;
rdfs:domain rdf:CompoundLiteral ;
rdfs:isDefinedBy <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
rdfs:seeAlso <https://www.w3.org/TR/json-ld11/#the-rdf-compoundliteral-class-and-the-rdf-language-and-rdf-direction-properties> .
16 changes: 10 additions & 6 deletions test/data/fetcher.py
Expand Up @@ -194,12 +194,12 @@ def _member_io(
pattern=re.compile(r"^(.+)$"),
),
# NOTE: Commented out as these files contains local modifications.
# ArchiveResource(
# remote="https://www.w3.org/2013/RDFXMLTests/TESTS.zip",
# local_path=(DATA_PATH / "suites" / "w3c" / "rdfxml"),
# type=ArchiveType.ZIP,
# pattern=re.compile(r"^(.+)$"),
# ),
ArchiveResource(
remote="https://www.w3.org/2013/RDFXMLTests/TESTS.zip",
local_path=(DATA_PATH / "suites" / "w3c" / "rdf-xml"),
type=ArchiveType.ZIP,
pattern=re.compile(r"^(.+)$"),
),
# NOTE: Commented out as this contains local modifications.
ArchiveResource(
remote="https://www.w3.org/2009/sparql/docs/tests/sparql11-test-suite-20121023.tar.gz",
Expand Down Expand Up @@ -232,6 +232,10 @@ def _member_io(
remote=Request("https://www.w3.org/2001/sw/DataAccess/tests/test-dawg#"),
local_path=(DATA_PATH / "defined_namespaces/dawgt.ttl"),
),
FileResource(
remote=Request("https://www.w3.org/1999/02/22-rdf-syntax-ns#"),
local_path=(DATA_PATH / "defined_namespaces/rdf.ttl"),
),
FileResource(
remote=Request("https://www.w3.org/2001/sw/DataAccess/tests/test-query#"),
local_path=(DATA_PATH / "defined_namespaces/qt.ttl"),
Expand Down

0 comments on commit 2f9f586

Please sign in to comment.