Skip to content

Commit

Permalink
Add more namespaces to test utils
Browse files Browse the repository at this point in the history
This patch adds the following namespaces to `test.utils.namespace` as
`DefinedNamespace`s:

- DAWGT: `http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#`
- MF: `http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#`
- QT: `http://www.w3.org/2001/sw/DataAccess/tests/test-query#`
- UT: `http://www.w3.org/2009/sparql/tests/test-update#`

Other changes:

- Change `test_sparql_w3c.py` to use the new defined namespaces.
- Change logging format for pytest to include milliseconds so it is
  easier to see what is slow.
- Ignore `-N815` for `test/utils/namespace/_*`
- Add source files for manifests to `test/data/defined_namespaces`, this
  is so we can use them in tests.
  • Loading branch information
aucampia committed Jun 4, 2022
1 parent aa33f9a commit 50e05e7
Show file tree
Hide file tree
Showing 16 changed files with 568 additions and 34 deletions.
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pep8-naming = ["-N802", "-N803", "-N806", "-N816"]
pep8-naming = ["-N802", "-N806", "-N815"]
[tool.flakeheaven.exceptions."rdflib/__init__.py"]
pycodestyle = ["-E402"]
[tool.flakeheaven.exceptions."test/utils/namespace/_*"]
pep8-naming = ["-N815"]


[tool.black]
Expand Down Expand Up @@ -76,5 +78,7 @@ filterwarnings = [
]
# log_cli = true
# log_cli_level = "DEBUG"
log_cli_format = "%(asctime)s %(levelname)-8s %(name)-12s %(filename)s:%(lineno)s:%(funcName)s %(message)s"
log_format = "%(asctime)s.%(msecs)03d %(levelname)-8s %(name)-12s %(filename)s:%(lineno)s:%(funcName)s %(message)s"
log_date_format = "%Y-%m-%dT%H:%M:%S"
log_cli_format = "%(asctime)s.%(msecs)03d %(levelname)-8s %(name)-12s %(filename)s:%(lineno)s:%(funcName)s %(message)s"
log_cli_date_format = "%Y-%m-%dT%H:%M:%S"
116 changes: 116 additions & 0 deletions test/data/defined_namespaces/dawgt.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix dawgt: <http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#> .
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .

# RDF Core tests
@prefix rct: <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#> .

dawgt: rdfs:comment "Vocabulary for DAWG test cases" ;
dc:creator "Andy Seaborne" ;
dc:subject "" ;
dc:publisher "W3C RDF Data Access Working Group" ;
dc:title "Vocabulary for DAWG test cases" ;
dc:description "Vocabulary for DAWG test cases" ;
dc:date "2004-07" ;
dc:format "RDF" ;
dc:identifier dawgt: ;
.


## ---- Classes ----

dawgt:ResultForm rdf:type rdfs:Class ;
rdfs:comment "Super class of all result forms" ;
.

dawgt:Status rdf:type rdfs:Class ;
rdfs:comment "Super class of all test status classes" ;
.

## ---- Properties ----

# Could be a subPropertyOf rdf:type
# or could just use rdf:type.
dawgt:resultForm rdf:type rdf:Property ;
rdfs:range dawgt:ResultForm ;
rdfs:isDefinedBy dawgt: ;
.

#dawgt:status rdf:type rdf:Property ;
# rdfs:range dawgt:Status ;
# rdfs:isDefinedBy dawgt: ;
# rdfs:label "Status" ;
# .

dawgt:approval rdf:type rdf:Property ;
rdfs:range dawgt:Status ;
rdfs:isDefinedBy dawgt: ;
rdfs:comment "The approval status of the test with respect to the working group." ;
rdfs:label "Approval" ;
.

dawgt:approvedBy rdf:type rdf:Property ;
rdfs:comment "Contains a reference to the minutes of the RDF Data Access Working Group where the test case status was last changed." ;
rdfs:label "Approval" ;
owl:sameAs rct:approval ;
.

dawgt:description rdf:type rdf:Property ;
rdfs:comment "A human-readable summary of the test case.";
rdfs:label "Description" ;
owl:sameAs rct:description ;
.

dawgt:issue rdf:type rdf:Property ;
rdfs:comment "Contains a pointer to the associated issue on the RDF Data Access Working Group Tracking document.";
owl:sameAs rct:issue ;
rdfs:label "Issue" .

dawgt:warning rdf:type rdf:Property;
rdfs:comment "Indicates that while the test should pass, it may generate a warning.";
owl:sameAs rct:warning ;
rdfs:label "Warning" .

## ---- Defined terms ----

## ---- Test statuses

dawgt:NotClassified rdfs:subClassOf dawgt:Status ;
rdfs:comment "Class of tests that have not been classified" ;
rdfs:label "NotClassified" .

dawgt:Approved rdfs:subClassOf dawgt:Status ;
rdfs:comment "Class of tests that are Approved" ;
rdfs:label "Approved" .

dawgt:Rejected rdfs:subClassOf dawgt:Status ;
rdfs:comment "Class of tests that are Rejected" ;
rdfs:label "Rejected" .

dawgt:Obsoleted rdfs:subClassOf dawgt:Status ;
rdfs:comment "Class of tests that are Obsolete" ;
rdfs:label "Obsoleted" .

dawgt:Withdrawn rdfs:subClassOf dawgt:Status ;
rdfs:comment "Class of tests that have been Withdrawn" ;
rdfs:label "Withdrawn" .


## ---- Result forms
## The result may still be encoded in RDF - classifying it helps
## check for expected form.

dawgt:ResultSet rdfs:subClassOf dawgt:ResultForm ;
rdfs:comment "Class of result expected to be from a SELECT query" ;
rdfs:label "Result Set" .

dawgt:ResultGraph rdfs:subClassOf dawgt:ResultForm ;
rdfs:comment "Class of result expected to be a graph" ;
rdfs:label "Graph Result" .

dawgt:ResultBoolean rdfs:subClassOf dawgt:ResultForm ;
rdfs:comment "Class of result expected to be a boolean" ;
rdfs:label "Boolean Result" .
178 changes: 178 additions & 0 deletions test/data/defined_namespaces/mf.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix : <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .

## A Manifest is typically a list (RDF Collection) of manifest entries.
## The :entries property has an object of the list.
## There may be more than one list per file.

: rdfs:comment "Manifest vocabulary for test cases" ;
dc:creator "Andy Seaborne" ;
dc:subject "" ;
dc:publisher "W3C RDF Data Access Working Group" ;
dc:title "Test case manifest vocabulary" ;
dc:description "Test case manifest vocabulary" ;
dc:date "2004-07" ;
dc:format "RDF" ;
dc:identifier : ;
.

## ---- Class declarations ----

:Manifest rdf:type rdfs:Class ;
rdfs:comment "The class of manifests" .

:ManifestEntry rdf:type rdfs:Class ;
rdfs:comment "One entry in rdf:type list of entries" .

## ---- Property declarations for the manifest ----

:include rdf:type rdf:Property ;
rdfs:comment "Connects the manifest resource to rdf:type list of manifests" ;
rdfs:domain :Manifest ;
rdfs:range rdf:List ;
.

:entries rdf:type rdf:Property ;
rdfs:comment "Connects the manifest resource to rdf:type list of entries" ;
rdfs:domain :Manifest ;
rdfs:range rdf:List ;

.

## ---- Property declarations for each test ----

:name rdf:type rdf:Property ;
rdfs:comment "Optional name of this entry" ;
rdfs:domain :ManifestEntry ;
rdfs:range rdfs:Literal ;
.

:action rdf:type rdf:Property ;
rdfs:comment "Action to perform" ;
rdfs:domain :ManifestEntry ;
# rdfs:range ?? ;
.

:result rdf:type rdf:Property ;
rdfs:comment "The expected outcome" ;
rdfs:domain :ManifestEntry ;
# rdfs:range ?? ;
.

:result rdf:type rdf:Property ;
rdfs:comment "The test status" ;
rdfs:domain :ManifestEntry ;
rdfs:range :TestStatus ;
.

:requires rdf:type rdf:Property ;
rdfs:comment "Required functionality for execution of this test" ;
rdfs:domain :ManifestEntry ;
rdfs:range :Requirement .

:notable rdf:type rdf:Property ;
rdfs:comment "Notable feature of this test (advisory)" ;
rdfs:domain :ManifestEntry .

:resultCardinality rdf:type rdf:Property ;
rdfs:comment "Specifies whether passing the test requires strict or lax cardinality adherence" ;
rdfs:domain :ManifestEntry ;
rdfs:range :ResultCardinality .

## ---- Test Case Type ---

:PositiveSyntaxTest rdf:type rdfs:Class ;
rdfs:label "Positive Syntax Test" ;
rdfs:comment "A type of test specifically for syntax testing. Syntax tests are not required to have an associated result, only an action." .

:PositiveSyntaxTest11 rdf:type rdfs:Class ;
rdfs:label "Positive Syntax Test for SPARQL1.1 Query" ;
rdfs:comment "A type of test specifically for syntax testing of new features in the SPARQL1.1 Query Language. Syntax tests are not required to have an associated result, only an action." .

:PositiveUpdateSyntaxTest11 rdf:type rdfs:Class ;
rdfs:label "Positive Syntax Test for SPARQL1.1 Update" ;
rdfs:comment "A type of test specifically for syntax testing of SPARQL1.1 Update. Syntax tests are not required to have an associated result, only an action." .


:NegativeSyntaxTest rdf:type rdfs:Class ;
rdfs:label "Negative Syntax Test" ;
rdfs:comment "A type of test specifically for syntax testing. Syntax tests are not required to have an associated result, only an action. Negative syntax tests are tests of which the result should be a parser error." .

:NegativeSyntaxTest11 rdf:type rdfs:Class ;
rdfs:label "Negative Syntax Test for SPARQL1.1 Query" ;
rdfs:comment "A type of test specifically for syntax testing of new features in the SPARQL1.1 Query Language. Syntax tests are not required to have an associated result, only an action. Negative syntax tests are tests of which the result should be a parser error." .

:NegativeUpdateSyntaxTest11 rdf:type rdfs:Class ;
rdfs:label "Negative Syntax Test for SPARQL1.1 Update" ;
rdfs:comment "A type of test specifically for syntax testing of SPARQL1.1 Update. Syntax tests are not required to have an associated result, only an action. Negative syntax tests are tests of which the result should be a parser error." .


:QueryEvaluationTest rdf:type rdfs:Class ;
rdfs:label "Query Evaluation Test" ;
rdfs:comment "A type of test specifically for query evaluation testing. Query evaluation tests are required to have an associated input dataset, a query, and an expected output dataset." .

:UpdateEvaluationTest rdf:type rdfs:Class ;
rdfs:label "Update Evaluation Test" ;
rdfs:comment "The class of all SPARQL 1.1 Update evaluation tests" .

## ---- Test Statuses ----

:TestStatus rdf:type rdfs:Class ;
rdfs:comment "Statuses a test can have" ;
.

:proposed rdf:type :TestStatus ;
rdfs:label "proposed" ;
.

:accepted rdf:type :TestStatus ;
rdfs:label "accepted" ;
.

:rejected rdf:type :TestStatus ;
rdfs:label "rejected" ;
.

## ---- Required functions ----

:Requirement rdf:type rdfs:Class ;
rdfs:comment "Requirements for a particular test" .

:Notable rdf:type rdfs:Class ;
rdfs:comment "Requirements for a particular test" .


:XsdDateOperations rdf:type :Requirement ;
rdfs:comment "Tests that require xsd:date operations" .

:StringSimpleLiteralCmp rdf:type :Requirement ;
rdfs:comment "Tests that require simple literal is the same value as an xsd:string of the same lexicial form" .

:KnownTypesDefault2Neq rdf:type :Requirement ;
rdfs:comment "Values in disjoint value spaces are not equal" .

:LangTagAwareness rdf:type :Requirement ;
rdfs:comment "Tests that require langauge tag handling in FILTERs" .

## ---- Notable features ----

:IllFormedLiterals rdf:type :Notable ;
rdfs:comment "Tests that involve lexical forms which are illegal for the datatype" .

## ---- Test cardinality ----

:ResultCardinality rdf:type rdfs:Class ;
rdfs:comment "Potential modes of evaluating a test's results with respect to solution cardinality" .

:LaxCardinality rdf:type :ResultCardinality ;
rdfs:comment
"""The given mf:result for a test with an mf:resultCardinality of mf:ReducedCardinalityTest
is the results as if the REDUCED keyword were omitted. To pass such
a test, an implementation must produce a result set
with each solution in the expected results appearing at least once and
no more than the number of times it appears in the expected results. Of
course, there must also be no results produced that are not in the
expected results.""" .

76 changes: 76 additions & 0 deletions test/data/defined_namespaces/qt.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .

@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
@prefix : <http://www.w3.org/2001/sw/DataAccess/tests/test-query#> .

## Query-specific test vocabulary for a manifest action.

: rdfs:comment "Vocabulary for query test cases" ;
dc:creator "Andy Seaborne" ;
dc:subject "" ;
dc:publisher "W3C RDF Data Access Working Group" ;
dc:title "Query test case vocabulary" ;
dc:description "Query test case vocabulary" ;
dc:date "2004-07" ;
dc:format "RDF" ;
dc:identifier : ;
.
## ---- Class declarations ----

:QueryTest a rdfs:Class ;
rdfs:comment "The class of query tests" .

:QueryForm rdf:type rdfs:Class ;
rdfs:comment "Super class of all query forms" ;
.


## ---- Property declarations ----


:query a rdf:Property ;
rdfs:comment "The query to ask" ;
rdfs:domain :QueryTest ;
## rdfs:range ?? ;
.

:data a rdf:Property ;
rdfs:comment "Optional: data for the query test" ;
rdfs:domain :QueryTest ;
rdfs:range rdfs:Resource ;
.

:graphData a rdf:Property ;
rdfs:comment "Optional: named-graph only data for the query test (ie. not loaded into the background graph)" ;
rdfs:domain :QueryTest ;
rdfs:range rdfs:Resource ;
.

# Could be a subPropertyOf rdf:type
# or could just use rdf:type.
:queryForm rdf:type rdf:Property ;
rdfs:range :QueryForm ;
rdfs:isDefinedBy : ;
.

## ---- Query forms
## The types of query there are

:QuerySelect rdfs:subClassOf :QueryForm ;
rdfs:comment "Class of queries that are seeking variable bindings" ;
rdfs:label "Variable Binding Query" .

:QueryConstruct rdfs:subClassOf :QueryForm ;
rdfs:comment "Class of queries that are seeking a constructed graph" ;
rdfs:label "Defined Graph Query" .

:QueryDescribe rdfs:subClassOf :QueryForm ;
rdfs:comment "Class of queries that are seeking a descriptive graph" ;
rdfs:label "Open Graph Query" .

:QueryAsk rdfs:subClassOf :QueryForm ;
rdfs:comment "Class of queries that are seeking a yes/no question" ;
rdfs:label "Boolean Query" .

0 comments on commit 50e05e7

Please sign in to comment.