User Tools

Site Tools


tests:loki-queries:ask

Tests: Loki ASK Queries

  • Delete lib/plugins/loki/temp/loki/tests/loki-ask.txt file before tests
  • Tests are performed manually - you have to compare if sections “Expected result” and “Actual result” represent the same thing!

Standard table results

Description: Simple table with results and additional headers. All elements in querytest category are shown.

Code:

{{#ask: [[category:querytest]] |
?test_title=Title |
?test_year=Year |
?test_lang |
?test_location |
?test_length |
?test_other_page |
default=No results! |
mainlabel=Main label |
intro=Text before results |
outro=Text after results
}}

Expected result:

Text before results

Main label Title Year Test_lang Test_location Test_length Test_other_page
page1 Długi tytuł testowy 2015 english polish 100 page2
page2 1900 internet 140 nonexisting-page
page1
page3 Krzysztof Trzeci Kutt homepage 2013
2016
123
124
ask
sparql
page4 Lorem Ipsum! 1410 latin Wszędzie 666
page5 Pięć Cztery Trzy Dwa Jeden 1633 latin Kraków
Moskwa
1234
page6 I jeszcze jeden test 1999 polish Kraków abc
page7 Miejsce na twoją reklamę dzisiaj english internet 1 page1

Text after results

Actual result:

Text before results

Main labelTitleYearTest_langTest_locationTest_lengthTest_other_page
page1D\uFFFD\uFFFDugi tytu\uFFFD\uFFFD testowy2015english
polish
100page2
page21900internet140nonexist-page
page1
page4Lorem Ipsum!1410latinWsz\uFFFD\uFFFDdzie666
page5Pi\uFFFD\uFFFD\uFFFD\uFFFD Cztery Trzy Dwa Jeden1633latinKrak\uFFFD\uFFFDw
Moskwa
1234
page6I jeszcze jeden test1999polishKrak\uFFFD\uFFFDwabc
page7To jest miejsce na reklam\uFFFD\uFFFDdzisiajenglishinternet1page1
Text after results

Results as a list

Description: Results as a enumeration + AND and OR conjunctions used in query. Query lists all pages which have test_length equal 1 or 123.

Code:

{{#ask: [[category:querytest]] [[test_length:=1||123]] |
?test_title=Title |
?test_lang |
?test_length |
default=No results! |
format=ol
}}

Expected result:

Nazwy stron i nazwy atrybutów powinny być linkami (nazwy stron do istniejących stron, nazwy atrybutów do nieistniejących stron tych atrybutów)

  1. page3 (Title Krzysztof Trzeci Kutt homepage, Test_lang , Test_length 123, 124, )
  2. page7 (Title Miejsce na twoją reklamę, Test_lang english, Test_length 1, )

Test:

  1. page7 (Title To jest miejsce na reklam\uFFFD\uFFFD, Test_lang english, Test_length 1, )

Subqueries

Opis: Subqueries + result as a row count. Subquery returns pages which have test_lang equal to english → page1 and page7. Next, “external” query returns pages that have test_other_page set to found pages page1 or page7 → page2 and page7. Result is displayed as a row count → 2.

Code:

{{#ask: [[category:querytest]] [[test_other_page::<q>[[category:querytest]] [[test_lang:=english]]</q>]] |
?test_title=Title |
?test_lang |
?test_length |
default=No results! |
format=count
}}

Expected result:

2

Actual result:

2

Partial tables

Opis: Row sort (lexically, 100 is before 2) + partial table using offset and limit; here results consist of 7 rows; we simulate showing 2nd page, with 3 results on each (so, we show rows 4-6) + links not placed in results

Code:

{{#ask: [[category:querytest]] |
?test_title=Title |
?test_length |
?test_other_page |
default=No results! |
sort=test_length |
link=none |
limit=3 |
offset=4
}}

Expected result:

Title Test_length Test_other_page
tests:loki-queries:page2 140 tests:loki-queries:nonexist-page
tests:loki-queries:page1
tests:loki-queries:page4 Lorem Ipsum! 666
tests:loki-queries:page5 Pięć Cztery Trzy Dwa Jeden 1234

Actual result:

TitleTest_lengthTest_other_page
tests:loki-queries:page4Lorem Ipsum!666
tests:loki-queries:page5Pi\uFFFD\uFFFD\uFFFD\uFFFD Cztery Trzy Dwa Jeden1234
tests:loki-queries:page6I jeszcze jeden testabc



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