Module:Protection banner/config/testcases: Difference between revisions

Content deleted Content added
Add module category tests
fix one
 
(44 intermediate revisions by 9 users not shown)
Line 1:
-- Unit tests for [[Module:Protection banner/config]]. Click talk page to run tests.
 
local pp = require('Module:Protection banner')
Line 22:
 
function suite:assertProtectionCategoryEquals(expected, action, level, namespace, reason, expiry)
local fakeTitleObjfakePageName = {namespace = namespace}'Foobar'
local fakeTitleObj = mw.title.new(fakePageName, namespace)
local protectionObj = suite.makeFakeProtectionObj(
{
Line 31 ⟶ 32:
expiry = expiry
},
cfgModule,
fakeTitleObj
)
local actual = protectionObj:makeProtectionCategory()
expected = string.format('[[Category:%s|%s]]', expected, fakePageName)
self:assertEquals(expected, actual)
end
Line 47 ⟶ 49:
d.pc = 'autoreview'
d.semi = 'autoconfirmed'
d.extended = 'extendedconfirmed'
d.template = 'templateeditor'
d.full = 'sysop'
d.dispute = 'dispute'
d.pc1 = 'autoconfirmed'
d.pc2 = 'reviewer'
d.vand = 'vandalism'
d.blp = 'blp'
Line 139 ⟶ 141:
--------------------------------------------------------------------------------
 
function suite:testCategory_move_full_template_dispute_alltestCategory_move_full_main_dispute_all()
self:assertProtectionCategoryEquals('Wikipedia pages move-protected due to dispute', d.move, d.full, 0, d.dispute, nil)
end
Line 184 ⟶ 186:
 
function suite:testCategory_edit_semi_file_vandalism_all()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected imagesfiles', d.edit, d.semi, 6, d.vand, nil)
end
 
function suite:testCategory_edit_semi_wikipedia_vandalism_all()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected project pages', d.edit, d.semi, 4, d.vand, nil)
end
 
function suite:testCategory_edit_semi_help_vandalism_all()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected project pages', d.edit, d.semi, 12, d.vand, nil)
end
 
function suite:testCategory_edit_semi_portal_vandalism_all()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected portals', d.edit, d.semi, 100, d.vand, nil)
end
 
Line 204 ⟶ 206:
 
function suite:testCategory_edit_semi_talk_vandalism_all()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected talk pages', d.edit, d.semi, 1, d.vand, nil)
end
 
Line 220 ⟶ 222:
 
function suite:testCategory_edit_semi_file_vandalism_temp()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected imagesfiles', d.edit, d.semi, 6, d.vand, d.temp)
end
 
function suite:testCategory_edit_semi_wikipedia_vandalism_temp()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected project pages', d.edit, d.semi, 4, d.vand, d.temp)
end
 
function suite:testCategory_edit_semi_help_vandalism_temp()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected project pages', d.edit, d.semi, 12, d.vand, d.temp)
end
 
function suite:testCategory_edit_semi_portal_vandalism_temp()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected portals', d.edit, d.semi, 100, d.vand, d.temp)
end
 
Line 240 ⟶ 242:
 
function suite:testCategory_edit_semi_talk_vandalism_temp()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected talk pages', d.edit, d.semi, 1, d.vand, d.temp)
end
 
Line 252 ⟶ 254:
 
function suite:testCategory_edit_full_user_vandalism_all()
self:assertProtectionCategoryEquals('Wikipedia fully protected user and user talk pages', d.edit, d.full, 2, d.vand, nil)
end
 
function suite:testCategory_edit_full_usertalk_vandalism_all()
self:assertProtectionCategoryEquals('Wikipedia fully protected user and user talk pages', d.edit, d.full, 3, d.vand, nil)
end
 
function suite:testCategory_edit_full_file_vandalism_all()
self:assertProtectionCategoryEquals('ProtectedWikipedia imagesfully protected files', d.edit, d.full, 6, d.vand, nil)
end
 
function suite:testCategory_edit_full_wikipedia_vandalism_all()
self:assertProtectionCategoryEquals('ProtectedWikipedia fully protected project pages', d.edit, d.full, 4, d.vand, nil)
end
 
function suite:testCategory_edit_full_help_vandalism_all()
self:assertProtectionCategoryEquals('ProtectedWikipedia fully protected project pages', d.edit, d.full, 12, d.vand, nil)
end
 
Line 276 ⟶ 278:
 
function suite:testCategory_edit_full_template_vandalism_all()
self:assertProtectionCategoryEquals('Wikipedia fully- protected templates', d.edit, d.full, 10, d.vand, nil)
end
 
function suite:testCategory_edit_full_talk_vandalism_all()
self:assertProtectionCategoryEquals('ProtectedWikipedia fully protected talk pages', d.edit, d.full, 1, d.vand, nil)
end
 
Line 288 ⟶ 290:
 
function suite:testCategory_edit_full_user_vandalism_temp()
self:assertProtectionCategoryEquals('Wikipedia fully protected user and user talk pages', d.edit, d.full, 2, d.vand, d.temp)
end
 
function suite:testCategory_edit_full_usertalk_vandalism_temp()
self:assertProtectionCategoryEquals('Wikipedia fully protected user and user talk pages', d.edit, d.full, 3, d.vand, d.temp)
end
 
function suite:testCategory_edit_full_file_vandalism_temp()
self:assertProtectionCategoryEquals('ProtectedWikipedia imagesfully protected files', d.edit, d.full, 6, d.vand, d.temp)
end
 
function suite:testCategory_edit_full_wikipedia_vandalism_temp()
self:assertProtectionCategoryEquals('ProtectedWikipedia fully protected project pages', d.edit, d.full, 4, d.vand, d.temp)
end
 
function suite:testCategory_edit_full_help_vandalism_temp()
self:assertProtectionCategoryEquals('ProtectedWikipedia fully protected project pages', d.edit, d.full, 12, d.vand, d.temp)
end
 
Line 312 ⟶ 314:
 
function suite:testCategory_edit_full_template_vandalism_temp()
self:assertProtectionCategoryEquals('Wikipedia fully- protected templates', d.edit, d.full, 10, d.vand, d.temp)
end
 
function suite:testCategory_edit_full_talk_vandalism_temp()
self:assertProtectionCategoryEquals('ProtectedWikipedia fully protected talk pages', d.edit, d.full, 1, d.vand, d.temp)
end
 
Line 412 ⟶ 414:
 
function suite:testCategory_edit_full_template_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully- protected templates', d.edit, d.full, 10, nil, nil)
end
 
function suite:testCategory_edit_full_template_all_temp()
self:assertProtectionCategoryEquals('Wikipedia fully- protected templates', d.edit, d.full, 10, nil, d.temp)
end
 
Line 425 ⟶ 427:
function suite:testCategory_edit_template_template_all_temp()
self:assertProtectionCategoryEquals('Wikipedia template-protected templates', d.edit, d.template, 10, nil, d.temp)
end
 
function suite:testCategory_edit_extended_template_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes extended-confirmed-protected pages (level 2)templates', d.pcedit, d.pc2extended, 10, nil, nil)
end
 
function suite:testCategory_move_template_template_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes template-protected pages (level 2)templates', d.pcmove, d.pc2template, 210, nil, nil)
end
 
Line 433 ⟶ 443:
function suite:testCategory_edit_full_template_all_temp()
self:assertProtectionCategoryEquals('Wikipedia move-protected templates', d.move, d.full, 10, nil, d.temp)
end
 
function suite:testCategory_edit_template_templatetalk_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes template-protected pages (levelother than templates and 2)modules', d.pcedit, d.pc2template, 311, nil, nil)
end
 
Line 440 ⟶ 454:
 
function suite:testCategory_edit_semi_module_all_all()
self:assertProtectionCategoryEquals('Wikipedia semi-protected modules', d.edit, d.semi, 10828, d.indef, nil)
end
 
function suite:testCategory_edit_semi_module_all_temp()
self:assertProtectionCategoryEquals('Wikipedia semi-protected modules', d.edit, d.semi, 10828, nil, d.temp)
end
 
function suite:testCategory_edit_full_module_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully- protected modules', d.edit, d.full, 10828, nil, nil)
end
 
function suite:testCategory_edit_full_module_all_temp()
self:assertProtectionCategoryEquals('Wikipedia fully- protected modules', d.edit, d.full, 10828, nil, d.temp)
end
 
function suite:testCategory_edit_template_module_all_all()
self:assertProtectionCategoryEquals('Wikipedia template-protected modules', d.edit, d.template, 10828, nil, nil)
end
 
function suite:testCategory_edit_template_module_all_temp()
self:assertProtectionCategoryEquals('Wikipedia template-protected modules', d.edit, d.template, 10828, nil, d.temp)
end
 
Line 476 ⟶ 490:
 
function suite:testCategory_edit_full_user_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully protected user and user talk pages', d.edit, d.full, 2, nil, nil)
end
 
function suite:testCategory_edit_full_usertalk_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully protected user and user talk pages', d.edit, d.full, 3, nil, nil)
end
 
Line 492 ⟶ 506:
 
function suite:testCategory_edit_full_user_all_temp()
self:assertProtectionCategoryEquals('Wikipedia fully protected user and user talk pages', d.edit, d.full, 2, nil, d.temp)
end
 
function suite:testCategory_edit_full_usertalk_all_temp()
self:assertProtectionCategoryEquals('Wikipedia fully protected user and user talk pages', d.edit, d.full, 3, nil, d.temp)
end
 
Line 680 ⟶ 694:
 
function suite:testCategory_edit_semi_file_all_indef()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected imagesfiles', d.edit, d.semi, 6, nil, d.indef)
end
 
function suite:testCategory_edit_semi_wikipedia_all_indef()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected project pages', d.edit, d.semi, 4, nil, d.indef)
end
 
function suite:testCategory_edit_semi_help_all_indef()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected project pages', d.edit, d.semi, 12, nil, d.indef)
end
 
function suite:testCategory_edit_semi_portal_all_indef()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected portals', d.edit, d.semi, 100, nil, d.indef)
end
 
Line 700 ⟶ 714:
 
function suite:testCategory_edit_semi_talk_all_indef()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected talk pages', d.edit, d.semi, 1, nil, d.indef)
end
 
function suite:testCategory_edit_semi_main_all_indef()
self:assertProtectionCategoryEquals('Wikipedia indefinitely semi-protected pages', d.edit, d.semi, 0, nil, d.indef)
end
 
function suite:testCategory_edit_semi_main_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changesindefinitely semi-protected pages (level 2)', d.pcedit, d.pc2semi, 0, nil, nil)
end
 
Line 745 ⟶ 763:
function suite:testCategory_move_full_main_all_indef()
self:assertProtectionCategoryEquals('Wikipedia indefinitely move-protected pages', d.move, d.full, 0, nil, d.indef)
end
 
function suite:testCategory_move_full_main_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changesindefinitely move-protected pages (level 2)', d.pcmove, d.pc2full, 60, nil, nil)
end
 
Line 760 ⟶ 782:
 
function suite:testCategory_edit_semi_file_all_all()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected imagesfiles', d.edit, d.semi, 6, nil, nil)
end
 
function suite:testCategory_edit_semi_wikipedia_all_all()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected project pages', d.edit, d.semi, 4, nil, nil)
end
 
function suite:testCategory_edit_semi_help_all_all()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected project pages', d.edit, d.semi, 12, nil, nil)
end
 
function suite:testCategory_edit_semi_portal_all_all()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected portals', d.edit, d.semi, 100, nil, nil)
end
 
Line 784 ⟶ 806:
 
function suite:testCategory_edit_semi_talk_all_all()
self:assertProtectionCategoryEquals('SemiWikipedia semi-protected talk pages', d.edit, d.semi, 1, nil, nil)
end
 
function suite:testCategory_edit_semi_main_all_alltestCategory_edit_semi_main_all_temp()
self:assertProtectionCategoryEquals('Wikipedia semi-protected pages', d.edit, d.semi, 0, nil, nild.temp)
end
 
function suite:testCategory_edit_extended_main_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes extended-confirmed-protected pages (level 2)', d.pcedit, d.pc2extended, 40, nil, nil)
end
 
function suite:testCategory_edit_full_user_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully protected user and user talk pages', d.edit, d.full, 2, nil, nil)
end
 
function suite:testCategory_edit_full_usertalk_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully protected user and user talk pages', d.edit, d.full, 3, nil, nil)
end
 
function suite:testCategory_edit_full_file_all_all()
self:assertProtectionCategoryEquals('ProtectedWikipedia imagesfully protected files', d.edit, d.full, 6, nil, nil)
end
 
function suite:testCategory_edit_full_wikipedia_all_all()
self:assertProtectionCategoryEquals('ProtectedWikipedia fully protected project pages', d.edit, d.full, 4, nil, nil)
end
 
function suite:testCategory_edit_full_help_all_all()
self:assertProtectionCategoryEquals('ProtectedWikipedia fully protected project pages', d.edit, d.full, 12, nil, nil)
end
 
function suite:testCategory_edit_full_portal_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully protected pages', d.edit, d.full, 100, nil, nil)
end
 
function suite:testCategory_edit_full_template_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully- protected templates', d.edit, d.full, 10, nil, nil)
end
 
function suite:testCategory_edit_full_category_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully protected categories', d.edit, d.full, 14, nil, nil)
end
 
function suite:testCategory_edit_full_talk_all_all()
self:assertProtectionCategoryEquals('ProtectedWikipedia fully protected talk pages', d.edit, d.full, 1, nil, nil)
end
 
function suite:testCategory_edit_full_main_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully protected pages', d.edit, d.full, 0, nil, nil)
end
 
Line 871 ⟶ 897:
end
 
function suite:testCategory_move_full_main_all_alltestCategory_move_full_main_all_temp()
self:assertProtectionCategoryEquals('Wikipedia move-protected pages', d.move, d.full, 0, nil, nild.temp)
end
 
function suite:testCategory_move_extended_main_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes extended-confirmed-protected pages (level 2)', d.pcmove, d.pc2extended, 10, nil, nil)
end
 
function suite:testCategory_move_extended_template_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes extended-confirmed-protected pages (level 2)templates', d.pcmove, d.pc2extended, 1210, nil, nil)
end
 
Line 912 ⟶ 946:
 
function suite:testCategory_pc_pc1_user_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 1)', d.pc, d.pc1, 2, nil, nil)
end
 
function suite:testCategory_pc_pc1_usertalk_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 1)', d.pc, d.pc1, 3, nil, nil)
end
 
function suite:testCategory_pc_pc1_file_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 1)', d.pc, d.pc1, 6, nil, nil)
end
 
function suite:testCategory_pc_pc1_wikipedia_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 1)', d.pc, d.pc1, 4, nil, nil)
end
 
function suite:testCategory_pc_pc1_help_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 1)', d.pc, d.pc1, 12, nil, nil)
end
 
function suite:testCategory_pc_pc1_portal_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 1)', d.pc, d.pc1, 100, nil, nil)
end
 
function suite:testCategory_pc_pc1_template_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 1)', d.pc, d.pc1, 10, nil, nil)
end
 
function suite:testCategory_pc_pc1_category_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 1)', d.pc, d.pc1, 14, nil, nil)
end
 
function suite:testCategory_pc_pc1_talk_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 1)', d.pc, d.pc1, 1, nil, nil)
end
 
function suite:testCategory_pc_pc1_main_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 1)', d.pc, d.pc1, 0, nil, nil)
end
 
--------------------------------------------------------------------------------
-- Categories: pending changes level 2
--------------------------------------------------------------------------------
 
function suite:testCategory_pc_pc2_user_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 2)', d.pc, d.pc2, 2, nil, nil)
end
 
function suite:testCategory_pc_pc2_usertalk_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 2)', d.pc, d.pc2, 3, nil, nil)
end
 
function suite:testCategory_pc_pc2_file_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 2)', d.pc, d.pc2, 6, nil, nil)
end
 
function suite:testCategory_pc_pc2_wikipedia_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 2)', d.pc, d.pc2, 4, nil, nil)
end
 
function suite:testCategory_pc_pc2_help_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 2)', d.pc, d.pc2, 12, nil, nil)
end
 
function suite:testCategory_pc_pc2_portal_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 2)', d.pc, d.pc2, 100, nil, nil)
end
 
function suite:testCategory_pc_pc2_template_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 2)', d.pc, d.pc2, 10, nil, nil)
end
 
function suite:testCategory_pc_pc2_category_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 2)', d.pc, d.pc2, 14, nil, nil)
end
 
function suite:testCategory_pc_pc2_talk_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 2)', d.pc, d.pc2, 1, nil, nil)
end
 
function suite:testCategory_pc_pc2_main_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages (level 2)', d.pc, d.pc2, 0, nil, nil)
end