Module:Infobox/Cycliste/Test

 Documentation[voir] [modifier] [historique] [purger]

Cette page définit un module d'infobox.


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:Infobox/Cycliste/forTest|testlocal|firstValue|Q6242|P31|id}}','Q5') 
	self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|firstValue|Q6242|P31|numeric-id}}','5') 
--Q57084526 is Paris-Roubaix 2019, time
	self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|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:Infobox/Cycliste/forTest|testlocal|firstValue|Q30125049|P1545}}','1') 
	self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|firstValue|Q30125049|P1545|value}}','1') 
end

function p:test_getStatementForTime()
	--Thomas Voeckler is Q312273
	self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|getStatementForTime|Q312273|P54|+2019-01-01T00:00:00Z}}','nil') 	
	self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|getStatementForTime|Q312273|P54|+2017-07-24T00:00:00Z}}','nil') 
	self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|getStatementForTime|Q312273|P54|+2017-07-23T00:00:00Z}}','Q195833')
	self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|getStatementForTime|Q312273|P54|+2017-01-01T00:00:00Z}}','Q195833') 
end

function p:test_getTeamLinkCat()
	if wiki=="fr" then
		self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|getTeamLinkCat|Q195833|+2019-01-01T00:00:00Z|false|false}}','[[Équipe cycliste Total Direct Énergie|Direct Énergie]]')
		self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|getTeamLinkCat2|Q1892064|+1993-01-01T00:00:00Z|false|false}}','Q20639847')
		self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|getTeamLinkCat2|Q1892064|+1998-01-01T00:00:00Z|false|false}}','Q20639847') 
		self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|getTeamLinkCat2|Q1892064|+1999-01-01T00:00:00Z|false|false}}','Q20653563')
		self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|getTeamLinkCat2|Q1892064|+2001-01-01T00:00:00Z|false|false}}','Q20653563')
		self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|getTeamLinkCat2|Q537946|+2011-01-01T00:00:00Z|false|false}}','Q2466826')
		self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|getTeamLinkCat2|Q537946|+2006-01-01T00:00:00Z|false|false}}','Q20639848')		
	end
end

function p:test_convertdate()
	self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|convertdate|0|0}}','+1900-01-01T00:00:00Z') 
	self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|convertdate|0|1}}','+2030-12-31T00:00:00Z')
	self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|convertdate|2019-00-00T00:00:00Z|0}}','+2019-01-01T00:00:00Z') 
	self:preprocess_equals('{{#invoke:Infobox/Cycliste/forTest|testlocal|convertdate|2019-00-00T00:00:00Z|1}}','+2019-12-31T00:00:00Z') 
end 

return p