Модул:Cycling race/Тест
Документацијата за овој модул можете да ја создадете на Модул:Cycling race/Тест/док
local p = require('Module:UnitTests')
local wiki = string.match(mw.site.server, "%a+")
function p:test_firstValue()
--Q6242 is Marianne Vos
--human?
self:preprocess_equals('{{#invoke:Cycling race|testlocal|firstValue|Q6242|P31|id}}','Q5')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|firstValue|Q6242|P31|numeric-id}}','5')
--Q57084526 is Paris-Roubaix 2019, time
self:preprocess_equals('{{#invoke:Cycling race|testlocal|firstValue|Q57084526|P585|time}}','+2019-04-14T00:00:00Z')
--Q30125049 is first stage of Tour de France 2019, stage order
self:preprocess_equals('{{#invoke:Cycling race|testlocal|firstValue|Q30125049|P1545}}','1')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|firstValue|Q30125049|P1545|value}}','1')
end
function p:test_func_date()
if wiki=="fr" then
--normal formatted date
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-04-14T00:00:00Z|long}}','14 avril 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-04-14T00:00:00Z|small}}','14 avr.')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-04-14T00:00:00Z|onlyday}}','14')
--1st January
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-01T00:00:00Z|long}}','1 janvier 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-01T00:00:00Z|small}}','1 janv.')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-01T00:00:00Z|onlyday}}','1')
--31th December
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-12-31T00:00:00Z|long}}','31 décembre 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-12-31T00:00:00Z|small}}','31 déc.')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-12-31T00:00:00Z|onlyday}}','31')
--insuffient precision, day
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-00T00:00:00Z|long}}','janvier 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-00T00:00:00Z|small}}','janv.')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-00T00:00:00Z|onlyday}}','-')
--insuffient precision, month and day
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-00-00T00:00:00Z|long}}','2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-00-00T00:00:00Z|small}}','-')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-00-00T00:00:00Z|onlyday}}','-')
elseif wiki=="ru" then
--normal formatted date
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-04-14T00:00:00Z|long}}','14 апреля 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-04-14T00:00:00Z|small}}','14 апр')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-04-14T00:00:00Z|onlyday}}','14')
--1st January
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-01T00:00:00Z|long}}','1 января 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-01T00:00:00Z|small}}','1 янв')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-01T00:00:00Z|onlyday}}','1')
--31th December
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-12-31T00:00:00Z|long}}','31 декабря 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-12-31T00:00:00Z|small}}','31 дек')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-12-31T00:00:00Z|onlyday}}','31')
--insuffient precision, day
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-00T00:00:00Z|long}}','января 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-00T00:00:00Z|small}}','янв')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-00T00:00:00Z|onlyday}}','-')
--insuffient precision, month and day
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-00-00T00:00:00Z|long}}','2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-00-00T00:00:00Z|small}}','-')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-00-00T00:00:00Z|onlyday}}','-')
elseif wiki=="mk" then
--normal formatted date
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-04-14T00:00:00Z|long}}','14 април 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-04-14T00:00:00Z|small}}','14 апр')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-04-14T00:00:00Z|onlyday}}','14')
--1st January
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-01T00:00:00Z|long}}','1 јануари 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-01T00:00:00Z|small}}','1 јан')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-01T00:00:00Z|onlyday}}','1')
--31th December
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-12-31T00:00:00Z|long}}','31 декември 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-12-31T00:00:00Z|small}}','31 дек')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-12-31T00:00:00Z|onlyday}}','31')
--insuffient precision, day
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-00T00:00:00Z|long}}','јануари 2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-00T00:00:00Z|small}}','јан')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-01-00T00:00:00Z|onlyday}}','-')
--insuffient precision, month and day
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-00-00T00:00:00Z|long}}','2019')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-00-00T00:00:00Z|small}}','-')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|func_date|+2019-00-00T00:00:00Z|onlyday}}','-')
end
end
function p:test_getRiderLink()
if wiki~="ru" and wiki~="mk" then
--Q6242 is Marianne Vos
-- simple case
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q6242|+2019-00-00T00:00:00Z}}','[[Marianne Vos|Marianne Vos]]')
-- future
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q6242|+2030-00-00T00:00:00Z}}','[[Marianne Vos|Marianne Vos]]')
--a man to change, Q220998=Tom Boonen
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q220998|+2019-00-00T00:00:00Z}}','[[Tom Boonen|Tom Boonen]]')
-- Lizzie Deignan / Armitstead Q254811
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q254811|+2010-00-00T00:00:00Z}}','[[Elizabeth Deignan|Lizzie Armitstead]]')
-- Lizzie Deignan / Armitstead Q254811
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q254811|+2019-00-00T00:00:00Z}}','[[Elizabeth Deignan|Lizzie Deignan]]')
-- Robert Millar Q711397
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q711397|+2010-00-00T00:00:00Z}}','[[Philippa York|Robert Millar]]')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q711397|+2019-00-00T00:00:00Z}}','[[Philippa York|Philippa York]]')
elseif wiki=="ru" then
--Q6242 is Marianne Vos
-- simple case
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q6242|+2019-00-00T00:00:00Z}}','[[Вос, Марианна|Марианна Вос]]')
-- future
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q6242|+2030-00-00T00:00:00Z}}','[[Вос, Марианна|Марианна Вос]]')
--a man to change, Q220998=Tom Boonen
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q220998|+2019-00-00T00:00:00Z}}','[[Бонен, Том|Том Бонен]]')
-- Lizzie Deignan / Armitstead Q254811
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q254811|+2010-00-00T00:00:00Z}}','Лиззи Армитстед')
-- Lizzie Deignan / Armitstead Q254811
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q254811|+2019-00-00T00:00:00Z}}','Лиззи Дейгнан')
-- Robert Millar Q711397
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q711397|+2010-00-00T00:00:00Z}}','[[Йорк, Филиппа|Роберт Миллар]]')
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q711397|+2019-00-00T00:00:00Z}}','[[Йорк, Филиппа|Филиппа Йорк]]')
elseif wiki=="mk" then
--a man to change, Q220998=Tom Boonen
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q220998|+2019-00-00T00:00:00Z}}','[[Том Бонен|Том Бонен]]')
-- Lizzie Deignan / Armitstead Q254811
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q254811|+2010-00-00T00:00:00Z}}','Лизи Армитстед')
-- Lizzie Deignan / Armitstead Q254811
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q254811|+2019-00-00T00:00:00Z}}','Лизи Армитстед') --not implemented in MK
-- Viatcheslav Kouznetsov Q2120951
self:preprocess_equals('{{#invoke:Cycling race|testlocal|getRiderLink|Q711397|+2019-00-00T00:00:00Z}}','[[Вјачеслав Кузнецов (велосипедист)|Вјачеслав Кузнецов]]')
end
end
return p