-- Unit tests for [[Module:{{ROOTPAGENAME}}]]. Click talk page to run tests.
local p = require('Module:UnitTests')
function p:test_main()
-- number of seats of a single European party in an institution
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|PPE|CE}}', '11')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|PSE|PE}}', '136')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|ALDE|EUCO}}', '3')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|ALE|CdR}}', '17')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|IND|EUCO}}', '4')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|ALDE|camera-bassa}}', '411')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|ALDE|camera-alta}}', '103')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|Q208242|camera-alta}}', '446')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|Q208242|CE}}', '11')
-- number of seats of a single national party in an institution
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|Q13564543|PE}}', '2')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|Q13564543|camera-bassa}}', '17')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|Q13564543|camera-alta}}', '1')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|Q22748|PE}}', '1')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|Q22748|camera-bassa}}', '1')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|Q173152|camera-bassa}}', 'error')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|Q173152|ep}}', 'error')
-- share of seats of a single European party in an institution
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|PPE|CE}}', '40.74')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|PSE|PE}}', '18.89')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|ALDE|EUCO}}', '11.11')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|PPE|CdR}}', '35.87')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|ALDE|camera-bassa}}', '6.51')
-- share of seats of a single national party in an institution
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|quota_di_seggi|Q13564543|PE}}', '10.53')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|quota_di_seggi|Q13564543|EP|circoscrizione=10}}', '20')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|quota_di_seggi|Q13564543|camera-bassa}}', '9.29')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|quota_di_seggi|Q13564543|camera-alta}}', '1.67')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|quota_di_seggi|Q655611|camera-bassa}}', '2')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|quota_di_seggi|Q655611|camera-bassa|circoscrizione=61}}', '4.92')
-- number of seats of all combined European parties in an institution
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|tutti|CE}}', '21')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|tutti|PE}}', '635')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|tutti|EUCO}}', '22')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|tutti|CdR}}', '312')
--self:preprocess_equals('{{#invoke:European and national party data|main|seggi|camera-alta|tutti}}', '102')
-- share of seats of all combined European parties in an institution
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|tutti|CE}}', '77.78')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|tutti|PE}}', '88.19')
--self:preprocess_equals('{{#invoke:European and national party data|main|seggi|camera-bassa|tutti|%}}', '6.41')
-- number of seats not occupied by European parties in an institution
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|nessuno|CE}}', '6')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|NESSUNO|PE}}', '85')
-- share of seats not occupied by European parties in an institution
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|nessuno|CE}}', '22.22')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|NESSUNO|PE}}', '11.81')
-- get data from European party
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|acronimo|Q208242}}', 'EPP')
self:preprocess_equals_preprocess('{{#invoke:European and national party data|main|entita_europea|colore|PPE}}', '#3399FF ')
self:preprocess_equals_preprocess('{{#invoke:European and national party data|main|entita_europea|paese|Q208242}}', 'European Union')
self:preprocess_equals_preprocess('{{#invoke:European and national party data|main|entita_europea|data_fondazione|PSE}}', '10 November 1992 ')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|membri_individuali|Q208242}}', '25')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|membri_individuali|Q208242|referenza=si}}', '25')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|etichetta|Q208242}}', 'European People’s Party')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|nome_ufficiale|Q208242}}', 'European People’s Party')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|gruppo_parlamentare|PVE}}', 'The Greens–European Free Alliance')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|finanziamento_pubblico|PVE}}', '171,460.56 euro')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|finanziamento_pubblico|PVE|referenza=si}}', '171,460.56 euro')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|sito_web|Q208242}}', 'https://www.epp.eu')
-- get data from national party
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|acronimo|Q13564543}}', 'NEOS')
self:preprocess_equals_preprocess('{{#invoke:European and national party data|main|partito_nazionale|colore|Q22748}}', '#B5152B')
self:preprocess_equals_preprocess('{{#invoke:European and national party data|main|partito_nazionale|paese|Q22748}}', 'Germany')
self:preprocess_equals_preprocess('{{#invoke:European and national party data|main|partito_nazionale|data_fondazione|Q13564543}}', '27 October 2012')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|membri_individuali|Q49764}}', '54,214')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|etichetta|Q22748}}', 'Die Partei')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|nome_ufficiale|Q22748}}', 'Die Partei')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|nome_ufficiale|Q22748|verbose=si}}', 'Die Partei')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|gruppo_parlamentare|Q13564543}}', 'NEOS')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|finanziamento_pubblico|Q22748}}', '')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|sito_web|Q13564543}}', 'http://www.neos.eu')
-- testing error messages
-- missing or invalid party
self:preprocess_equals_preprocess('{{#invoke:European and national party data|main|entita_europea|seggi}}', 'error - not called from the page of a European party (help)')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi}}', 'error - not called from the page of a European party (help)')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|Q208|CE}}', 'error - European party or parameter not valid: Q208 (help)')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|Q208|CE}}', 'error - European party or parameter not valid: Q208 (help)')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi}}', 'error - National party not valid: THISPARTY (help)')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|quota_di_seggi}}', 'error - National party not valid: THISPARTY (help)')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|Q208|CE}}', 'error - institution EC has unknown party: Q208 (help)')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|quota_di_seggi|Q208|CE}}', 'error - institution EC has unknown party: Q208 (help)')
-- unknown institution
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|APPF}}', 'error - unknown institution: APPF')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|PPE|APPF}}', 'error - unknown institution: APPF')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|APPF}}', 'error - unknown institution: APPF')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|PPE|APPF}}', 'error - unknown institution: APPF')
-- unavailable parameter for lower/upper houses
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|tutti|camera-bassa}}', 'error - parameter not valid')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|nessuno|camera-alta}}', 'error - parameter not valid')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|IND|camera-alta}}', 'error - parameter not valid')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|tutti|camera-bassa}}', 'error - parameter not valid')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|nessuno|camera-alta}}', 'error - parameter not valid')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|IND|camera-alta}}', 'error - parameter not valid')
-- calling thisparty outside of the page of a European party
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|questopartito|CE}}', 'error - module not called from the page of a European party')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|questopartito|CE}}', 'error - module not called from the page of a European party')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|seggi|questopartito|camera-bassa}}', 'error - module not called from the page of a European party')
self:preprocess_equals('{{#invoke:European and national party data|main|entita_europea|quota_di_seggi|questopartito|camera-bassa}}', 'error - module not called from the page of a European party')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|questopartito|CE}}', 'error - module not called from the page of a national party')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|quota_di_seggi|questopartito|CE}}', 'error - module not called from the page of a national party')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|seggi|questopartito|camera-bassa}}', 'error - module not called from the page of a national party')
self:preprocess_equals('{{#invoke:European and national party data|main|partito_nazionale|quota_di_seggi|questopartito|camera-bassa}}', 'error - module not called from the page of a national party')
end
return p