Skip to content

Commit

Permalink
Initial implementation for RDF-based QueryEvaluationTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Mec-iS authored Mar 30, 2022
2 parents d95db13 + e23987a commit 540ffdc
Show file tree
Hide file tree
Showing 101 changed files with 2,850 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,5 @@ dmypy.json

# Pyre type checker
.pyre/

report-*
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ Then when you're ready to submit code for review, please use a
[pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request)
on our `main` repo branch.

## Testing
To start developing and run tests locally, it is needed to install dev requirements: `pip install -r requirements-dev.txt`
### basic testing
Testing that runs with CI/CD can be run with: `pytest tests/`

### RDF testing
For RDF-based tests on [RDF-tests](https://github.com/w3c/rdf-tests) manifests: `pytest tests/rdf_tests/test_rdf_basic.py -k test_rdf_runner -s`


## Project roadmap

Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ twine >= 3.8
types-python-dateutil >= 2.8
types-requests >= 2.27
wheel >= 0.37
xmltodict >= 0.12
5 changes: 5 additions & 0 deletions tests/rdf_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

## run RDF tests
```
$ pytest tests/rdf_tests/test_rdf_basic.py -k test_rdf_runner -s
```
1 change: 1 addition & 0 deletions tests/rdf_tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file added tests/rdf_tests/dat/.gitkeep
Empty file.
4 changes: 4 additions & 0 deletions tests/rdf_tests/dat/basic/base-prefix-1.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BASE <http://example.org/x/>
PREFIX : <>

SELECT * WHERE { :x ?p ?v }
28 changes: 28 additions & 0 deletions tests/rdf_tests/dat/basic/base-prefix-1.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<sparql
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xs="http://www.w3.org/2001/XMLSchema#"
xmlns="http://www.w3.org/2005/sparql-results#" >
<head>
<variable name="v"/>
<variable name="p"/>
</head>
<results>
<result>
<binding name="v">
<literal>d:x ns:p</literal>
</binding>
<binding name="p">
<uri>http://example.org/ns#p</uri>
</binding>
</result>
<result>
<binding name="v">
<literal>x:x x:p</literal>
</binding>
<binding name="p">
<uri>http://example.org/x/p</uri>
</binding>
</result>
</results>
</sparql>
4 changes: 4 additions & 0 deletions tests/rdf_tests/dat/basic/base-prefix-2.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BASE <http://example.org/x/>
PREFIX : <#>

SELECT * WHERE { :x ?p ?v }
20 changes: 20 additions & 0 deletions tests/rdf_tests/dat/basic/base-prefix-2.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<sparql
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xs="http://www.w3.org/2001/XMLSchema#"
xmlns="http://www.w3.org/2005/sparql-results#" >
<head>
<variable name="v"/>
<variable name="p"/>
</head>
<results>
<result>
<binding name="v">
<literal>z:x z:p</literal>
</binding>
<binding name="p">
<uri>http://example.org/x/#p</uri>
</binding>
</result>
</results>
</sparql>
4 changes: 4 additions & 0 deletions tests/rdf_tests/dat/basic/base-prefix-3.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PREFIX ns: <http://example.org/ns#>
PREFIX x: <http://example.org/x/>

SELECT * WHERE { x:x ns:p ?v }
16 changes: 16 additions & 0 deletions tests/rdf_tests/dat/basic/base-prefix-3.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<sparql
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xs="http://www.w3.org/2001/XMLSchema#"
xmlns="http://www.w3.org/2005/sparql-results#" >
<head>
<variable name="v"/>
</head>
<results>
<result>
<binding name="v">
<literal>d:x ns:p</literal>
</binding>
</result>
</results>
</sparql>
3 changes: 3 additions & 0 deletions tests/rdf_tests/dat/basic/base-prefix-4.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BASE <http://example.org/x/>

SELECT * WHERE { <x> <p> ?v }
16 changes: 16 additions & 0 deletions tests/rdf_tests/dat/basic/base-prefix-4.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<sparql
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xs="http://www.w3.org/2001/XMLSchema#"
xmlns="http://www.w3.org/2005/sparql-results#" >
<head>
<variable name="v"/>
</head>
<results>
<result>
<binding name="v">
<literal>x:x x:p</literal>
</binding>
</result>
</results>
</sparql>
3 changes: 3 additions & 0 deletions tests/rdf_tests/dat/basic/base-prefix-5.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BASE <http://example.org/x/>

SELECT * WHERE { <#x> <#p> ?v }
16 changes: 16 additions & 0 deletions tests/rdf_tests/dat/basic/base-prefix-5.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<sparql
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xs="http://www.w3.org/2001/XMLSchema#"
xmlns="http://www.w3.org/2005/sparql-results#" >
<head>
<variable name="v"/>
</head>
<results>
<result>
<binding name="v">
<literal>z:x z:p</literal>
</binding>
</result>
</results>
</sparql>
8 changes: 8 additions & 0 deletions tests/rdf_tests/dat/basic/bgp-no-match.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX : <http://example.org/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?x
WHERE {
?x foaf:name "John Smith" ;
a foaf:Womble .
}

10 changes: 10 additions & 0 deletions tests/rdf_tests/dat/basic/bgp-no-match.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<sparql
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xs="http://www.w3.org/2001/XMLSchema#"
xmlns="http://www.w3.org/2005/sparql-results#" >
<head>
<variable name="x"/>
</head>
<results />
</sparql>
8 changes: 8 additions & 0 deletions tests/rdf_tests/dat/basic/data-1.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@prefix ns: <http://example.org/ns#> .
@prefix x: <http://example.org/x/> .
@prefix z: <http://example.org/x/#> .

x:x ns:p "d:x ns:p" .
x:x x:p "x:x x:p" .

z:x z:p "z:x z:p" .
8 changes: 8 additions & 0 deletions tests/rdf_tests/dat/basic/data-2.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@prefix : <http://example.org/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .


:x :list0 () .
:x :list1 ("1"^^xsd:integer) .
:x :list2 ("11"^^xsd:integer "22"^^xsd:integer) .
:x :list3 ("111"^^xsd:integer "222"^^xsd:integer "333"^^xsd:integer) .
12 changes: 12 additions & 0 deletions tests/rdf_tests/dat/basic/data-3.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@prefix : <http://example.org/ns#> .

# This file uses UNIX line end conventions.

:x1 :p1 "x" .
:x2 :p2 """x
y""" .

:x3 :p3 """x
y"""^^:someType .


14 changes: 14 additions & 0 deletions tests/rdf_tests/dat/basic/data-4.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@prefix : <http://example.org/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

:x :p1 "true"^^xsd:boolean .
:x :p2 "false"^^xsd:boolean .

:x rdf:type :C .

:x :n1 "123.0"^^xsd:decimal .
:x :n2 "456."^^xsd:decimal .

:x :n3 "+5"^^xsd:integer .
:x :n4 "-18"^^xsd:integer .
5 changes: 5 additions & 0 deletions tests/rdf_tests/dat/basic/data-5.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@prefix : <http://example.org/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:x :p1 "1"^^xsd:integer .
:x :p2 "2"^^xsd:integer .
5 changes: 5 additions & 0 deletions tests/rdf_tests/dat/basic/data-6.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@prefix : <http://example.org/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:x :p1 "1"^^xsd:integer .
:x :p1 "2"^^xsd:integer .
7 changes: 7 additions & 0 deletions tests/rdf_tests/dat/basic/data-7.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@prefix : <http://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

:john a foaf:Person ;
foaf:name "John Smith" .


Loading

0 comments on commit 540ffdc

Please sign in to comment.