User Tools

Site Tools


tests:loki-queries:sparql

Tests: Loki SPARQL Queries

  • Tests are performed manually - you have to compare if sections “Expected result” and “Actual result” represent the same thing!
  • Tests can be run inside wiki (as below) or against Loki SPARQL Endpoint.

SELECT query

Description: SELECT query with FILTER() and ORDER BY

Code:

<pl format="sparql">
PREFIX wiki:   <>
SELECT ?page ?lang ?length
WHERE 
  { 
     ?page a "querytest".
     ?page wiki:test_lang ?lang.
     ?page wiki:test_length ?length.
     FILTER (?lang!='polish')
  }
ORDER BY INC(?length)
LIMIT 5
</pl>

Expected result:

page lang length
tests:loki-queries:page7 english 1
tests:loki-queries:page1 english 100
tests:loki-queries:page4 latin 666
tests:loki-queries:page5 latin 1234

Actual result:

pagelanglength
page7english1
page1english100
page4latin666
page5latin1234

ASK query

Description: Simple ASK queries

Code:

Are there any pages not in polish?
<pl format="sparql">
PREFIX wiki: <>
ASK {
     ?page a "querytest".
     ?page wiki:test_lang ?lang.
     FILTER (?lang!='polish')
}
</pl>
 
Are there any pages from year 2000? 
<pl format="sparql">
PREFIX wiki: <>
ASK {
     ?page a "querytest".
     ?page wiki:test_year ?year.
     FILTER (?year='2000')
}
</pl>

Expected result:

Are there any pages not in polish? yes

Are there any pages from year 2000? no

Actual result:

Are there any pages not in polish? yes

Are there any pages from year 2000? no

DESCRIBE query

Describe: Describe pages that are linked (as test_other_page) in other pages.

Code:

<pl format="sparql">
PREFIX wiki: <>
DESCRIBE ?other 
WHERE {
  ?page a "querytest" ;
         wiki:test_other_page ?other .
}
</pl>

Expected result:

tests:loki-queries:page1 a querytest ;
test_autor Krzysztof Kutt ;
test_lang english ,
polish ;
test_length 100 ;
test_other_page tests:loki-queries:page2 ;
test_title Długi tytuł testowy ;
test_year 2015 .
tests:loki-queries:page2 a querytest ;
test_autor Krzysztof Kutt ;
test_length 140 ;
test_location internet ;
test_other_page tests:loki-queries:nonexist-page ,
tests:loki-queries:page1 ;
test_year 1900 .

Actual result:

tests:loki-queries:page1 a querytest ;
test_autor Krzysztof Kutt ;
test_lang english ,
polish ;
test_length 100 ;
test_other_page tests:loki-queries:page2 ;
test_title D\uFFFD\uFFFDugi tytu\uFFFD\uFFFD testowy ;
test_year 2015 .
tests:loki-queries:page2 a querytest ;
test_autor Krzysztof Kutt ;
test_length 140 ;
test_location internet ;
test_other_page tests:loki-queries:nonexist-page ,
tests:loki-queries:page1 ;
test_year 1900 .



tests/loki-queries/sparql.txt · Last modified: 2017/09/19 16:31 (external edit)