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

Content deleted Content added
check if we get "error invalid action: foobar"
fix one
 
(23 intermediate revisions by 7 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 14:
 
function suite.makeFakeProtectionObj(fields, cfg, title)
local obj = Protection.new({action = 'foobar'}, cfg, title)
for k, v in pairs(fields) do
obj[k] = v
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 32 ⟶ 33:
},
cfgModule,
fakeTitleObj
mw.title.new('Test', 'Module')
)
local actual = protectionObj:makeProtectionCategory()
expected = string.format('[[Category:%s|%s]]', expected, fakePageName)
self:assertEquals(expected, actual)
end
Line 53 ⟶ 54:
d.dispute = 'dispute'
d.pc1 = 'autoconfirmed'
d.pc2 = 'reviewer'
d.vand = 'vandalism'
d.blp = 'blp'
Line 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 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('Wikipedia fully- protected files', d.edit, d.full, 6, d.vand, nil)
end
 
function suite:testCategory_edit_full_wikipedia_vandalism_all()
self:assertProtectionCategoryEquals('Wikipedia fully- protected project pages', d.edit, d.full, 4, d.vand, nil)
end
 
function suite:testCategory_edit_full_help_vandalism_all()
self:assertProtectionCategoryEquals('Wikipedia fully- protected project pages', d.edit, d.full, 12, d.vand, nil)
end
 
Line 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('Wikipedia fully- protected talk pages', d.edit, d.full, 1, d.vand, nil)
end
 
Line 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('Wikipedia fully- protected files', d.edit, d.full, 6, d.vand, d.temp)
end
 
function suite:testCategory_edit_full_wikipedia_vandalism_temp()
self:assertProtectionCategoryEquals('Wikipedia fully- protected project pages', d.edit, d.full, 4, d.vand, d.temp)
end
 
function suite:testCategory_edit_full_help_vandalism_temp()
self:assertProtectionCategoryEquals('Wikipedia fully- protected project pages', d.edit, d.full, 12, d.vand, d.temp)
end
 
Line 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('Wikipedia fully- protected talk pages', d.edit, d.full, 1, d.vand, d.temp)
end
 
Line 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 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 435 ⟶ 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 450 ⟶ 462:
 
function suite:testCategory_edit_full_module_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully- protected modules', d.edit, d.full, 828, nil, nil)
end
 
function suite:testCategory_edit_full_module_all_temp()
self:assertProtectionCategoryEquals('Wikipedia fully- protected modules', d.edit, d.full, 828, nil, d.temp)
end
 
Line 478 ⟶ 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 494 ⟶ 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 707 ⟶ 719:
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 747 ⟶ 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 789 ⟶ 809:
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 pages under 30extended-500confirmed-protected editing restrictionpages', d.edit, d.extended, 0, 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('Wikipedia fully- protected files', d.edit, d.full, 6, nil, nil)
end
 
function suite:testCategory_edit_full_wikipedia_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully- protected project pages', d.edit, d.full, 4, nil, nil)
end
 
function suite:testCategory_edit_full_help_all_all()
self:assertProtectionCategoryEquals('Wikipedia 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('Wikipedia 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 877 ⟶ 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, 40, 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 918 ⟶ 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