Modulo:Wikidata/test: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
+test redirect |
corretti wikilink dopo aggiornamento formatEntityId |
||
(7 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 20:
{ "P47|n=3", "[[Svedala (comune)|Svedala]]" },
-- rank
{ "P131|rank=preferred", "[[
-- rank best, ritorna il preferred
{ "P131|rank=best", "[[
-- rank best, in mancanza di preferred ritorna normal
{ "P94|rank=best", "Malmö fulla vapen.svg" },
-- rank + n
{ "P131|rank=preferred|n=1", "[[
{ "P131|rank=preferred|n=3", "" },
-- rank non esistente + n => stringa vuota
{ "P47|rank=preferred|n=1", "" },
-- qualifier
{ "P131|qualifier=P580", "[[
-- qualifier + qualifiervalue
{ "P131|qualifier=P580|qualifiervalue=1º gennaio 2007", "[[
-- qualifier + qualifiertype
{ "P131|qualifier=P580|qualifiertype=latest", "[[
-- noqualifier
{ "P131|noqualifier=P580", "[[Scania (provincia)|Scania]]" },
Riga 138:
function p:test_showqualifiers()
self:preprocess_equals_many("{{Wikidata/Sandbox|from=Q38|", "}}", {
{ "P38|showqualifiers=P580|rank=normal", "[[
-- qualifier multipli
{ "P38|showqualifiers=P580,P582|rank=normal", "[[
-- qualifier non esistenti
{ "P38|showqualifiers=P580x,P582x|rank=normal", "[[
})
end
Riga 205:
self:preprocess_equals_many("{{WikidataLabel/Sandbox|", "}}", {
-- property
{ "P17", "
{ "P17|en", "country" },
-- item
Riga 217:
-- sitelink e label => [[sitelink|label]]
{ "Q503361", "[[Malmö (comune)|Malmö]]" },
-- sitelink = label => [[label]]
{ "Q1067", "[[Dante Alighieri]]" },
-- sitelink = label (iniziale minuscola) => [[label]]
{ "Q5369", "[[baseball]]" },
-- solo sitelink => [[sitelink]]
-- { "", "" },
Line 222 ⟶ 226:
{ "Q504125", "Copenaghen" },
-- senza label e sitelink => label en
{ "
})
end
Line 228 ⟶ 232:
function p:test_getDatatype()
self:preprocess_equals_many("{{WikidataTipo/Sandbox|", "}}", {
{ "P10", "file multimediale su Commons" },
{ "
{ "P3896", "forma geografica" },
{ "P625", "coordinate geografiche" },
{ "P2534", "espressione matematica" },▼
{ "P1448", "testo monolingua" },
{ "P1082", "quantità" },
{ "P229", "stringa" },
{ "
{ "
{ "
{ "P17", "elemento" },
{ "P1659", "proprietà" }
▲ { "P2534", "espressione matematica" }
})
end
Line 328 ⟶ 334:
{ "from=Q3710|P2370|rounding=1|unit=cm", "30,5" },
{ "from=Q3710|P2370|rounding=2|unit=cm", "30,48" }
})
end
function p:test_getProperty_nil()
local mWikidata = require('Modulo:Wikidata/sandbox')
-- _getProperty restituisce nil:
-- se non è collegata a un elemento Wikidata
self:preprocess_equals(tostring(mWikidata._getProperty({ 'P94' })), 'nil')
-- se i risultati sono 0 perché l'elemento non esiste
self:preprocess_equals(tostring(mWikidata._getProperty({ 'P94', from = 'Q6' })), 'nil')
-- se i risultati sono 0 perché la proprietà non esiste in quell'elemento
self:preprocess_equals(tostring(mWikidata._getProperty({ 'P1447', from = 'Q503361' })), 'nil')
-- se i risultati sono 0 perché non ci sono valori della proprietà che soddisfano i criteri
self:preprocess_equals(tostring(mWikidata._getProperty({ 'P18', from = 'Q503361', n = 2 })), 'nil')
end
function p:test_getClaims_nil_or_empty()
local mWikidata = require('Modulo:Wikidata/sandbox')
-- _getClaims restituisce nil se non è collegata un elemento Wikidata
self:preprocess_equals(tostring(mWikidata._getClaims('P94')), 'nil')
-- _getClaims restituisce una sequence Lua vuota se:
-- l'elemento Wikidata specificato non esiste
self:preprocess_equals(tostring(#mWikidata._getClaims('P94', { from = 'Q6' })), '0')
-- l'elemento Wikidata non ha la proprietà specificata
self:preprocess_equals(tostring(#mWikidata._getClaims('P1447', { from = 'Q503361' })), '0')
-- non ci sono valori della proprietà specificata che soddisfano i criteri
self:preprocess_equals(tostring(#mWikidata._getClaims('P18', { from = 'Q503361', n = 2 })), '0')
end
function p:test_snaktype()
self:preprocess_equals_many("{{Wikidata/Sandbox|", "}}", {
-- test snaktype novalue
{ "from=Q7207|P40", "''nessun valore''" },
-- test snaktype somevalue
{ "from=Q24039104|P569", "''valore sconosciuto''" },
-- test parametro snaktype
{ "from=Q7207|P40|snaktype=novalue", "''nessun valore''" },
{ "from=Q7207|P40|snaktype=value", "" },
{ "from=Q7207|P31|snaktype=value", "umano" },
{ "from=Q24039104|P569|snaktype=somevalue", "''valore sconosciuto''" },
{ "from=Q24039104|P569|snaktype=value", "" },
{ "from=Q24039104|P31|snaktype=value", "umano" }
})
end
|