~~NOCACHE~~
====== 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 **[[http://loki.ia.agh.edu.pl/wiki/sparql/|Loki SPARQL Endpoint]]**.
===== SELECT query =====
**Description:** SELECT query with FILTER() and ORDER BY
**Code:**
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
**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:**
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
===== ASK query =====
**Description:** Simple ASK queries
**Code:**
Are there any pages not in polish?
PREFIX wiki: <>
ASK {
?page a "querytest".
?page wiki:test_lang ?lang.
FILTER (?lang!='polish')
}
Are there any pages from year 2000?
PREFIX wiki: <>
ASK {
?page a "querytest".
?page wiki:test_year ?year.
FILTER (?year='2000')
}
**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?
PREFIX wiki: <>
ASK {
?page a "querytest".
?page wiki:test_lang ?lang.
FILTER (?lang!='polish')
}
Are there any pages from year 2000?
PREFIX wiki: <>
ASK {
?page a "querytest".
?page wiki:test_year ?year.
FILTER (?year='2000')
}
===== DESCRIBE query =====
**Describe:** Describe pages that are linked (as ''test_other_page'') in other pages.
**Code:**
PREFIX wiki: <>
DESCRIBE ?other
WHERE {
?page a "querytest" ;
wiki:test_other_page ?other .
}
**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:**
PREFIX wiki: <>
DESCRIBE ?other
WHERE {
?page a "querytest" ;
wiki:test_other_page ?other .
}