Content deleted Content added
m Mr. Stradivarius moved page Module:Protection banner/testcases to Module:Protection banner/config/testcases without leaving a redirect: really, these are testcases for the config file, not the main module |
SilverLocust (talk | contribs) fix one |
||
(48 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')
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
local Protection = pp._exportClasses().Protection
-- Get the config
local
--------------------------------------------------------------------------------
Line 20 ⟶ 14:
function suite.makeFakeProtectionObj(fields, cfg, title)
local obj = Protection
for k, v in pairs(fields) do
obj[k] = v
end
return obj
end
function suite:assertProtectionCategoryEquals(expected, action, level, namespace, reason, expiry)
local
local fakeTitleObj = mw.title.new(fakePageName, namespace)
local protectionObj = suite.makeFakeProtectionObj(
{
Line 42 ⟶ 32:
expiry = expiry
},
cfgModule,
fakeTitleObj
)
local actual = protectionObj:makeProtectionCategory()
expected = string.format('[[Category:%s|%s]]', expected, fakePageName)
self:assertEquals(expected, actual)
end
Line 58 ⟶ 49:
d.pc = 'autoreview'
d.semi = 'autoconfirmed'
d.extended = 'extendedconfirmed'
d.template = 'templateeditor'
d.full = 'sysop'
d.dispute = 'dispute'
d.pc1 = 'autoconfirmed'
d.vand = 'vandalism'
d.blp = 'blp'
Line 150 ⟶ 141:
--------------------------------------------------------------------------------
function suite:
self:assertProtectionCategoryEquals('Wikipedia pages move-protected due to dispute', d.move, d.full, 0, d.dispute, nil)
end
Line 195 ⟶ 186:
function suite:testCategory_edit_semi_file_vandalism_all()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_wikipedia_vandalism_all()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_help_vandalism_all()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_portal_vandalism_all()
self:assertProtectionCategoryEquals('
end
Line 215 ⟶ 206:
function suite:testCategory_edit_semi_talk_vandalism_all()
self:assertProtectionCategoryEquals('
end
Line 231 ⟶ 222:
function suite:testCategory_edit_semi_file_vandalism_temp()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_wikipedia_vandalism_temp()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_help_vandalism_temp()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_portal_vandalism_temp()
self:assertProtectionCategoryEquals('
end
Line 251 ⟶ 242:
function suite:testCategory_edit_semi_talk_vandalism_temp()
self:assertProtectionCategoryEquals('
end
Line 263 ⟶ 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('
end
function suite:testCategory_edit_full_wikipedia_vandalism_all()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_full_help_vandalism_all()
self:assertProtectionCategoryEquals('
end
Line 287 ⟶ 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('
end
Line 299 ⟶ 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('
end
function suite:testCategory_edit_full_wikipedia_vandalism_temp()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_full_help_vandalism_temp()
self:assertProtectionCategoryEquals('
end
Line 323 ⟶ 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('
end
Line 423 ⟶ 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
function suite:testCategory_edit_template_template_all_all()
self:assertProtectionCategoryEquals('Wikipedia template-protected templates', d.edit, d.template, 10, nil, nil)
end
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 extended-confirmed-protected templates', d.edit, d.extended, 10, nil, nil)
end
function suite:testCategory_move_template_template_all_all()
self:assertProtectionCategoryEquals('Wikipedia template-protected templates', d.move, d.template, 10, nil, nil)
end
Line 444 ⟶ 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 template-protected pages other than templates and modules', d.edit, d.template, 11, nil, nil)
end
--------------------------------------------------------------------------------
-- Categories: module
--------------------------------------------------------------------------------
function suite:testCategory_edit_semi_module_all_all()
self:assertProtectionCategoryEquals('Wikipedia semi-protected modules', d.edit, d.semi, 828, d.indef, nil)
end
function suite:testCategory_edit_semi_module_all_temp()
self:assertProtectionCategoryEquals('Wikipedia semi-protected modules', d.edit, d.semi, 828, nil, d.temp)
end
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
function suite:testCategory_edit_template_module_all_all()
self:assertProtectionCategoryEquals('Wikipedia template-protected modules', d.edit, d.template, 828, nil, nil)
end
function suite:testCategory_edit_template_module_all_temp()
self:assertProtectionCategoryEquals('Wikipedia template-protected modules', d.edit, d.template, 828, nil, d.temp)
end
Line 459 ⟶ 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 475 ⟶ 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 663 ⟶ 694:
function suite:testCategory_edit_semi_file_all_indef()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_wikipedia_all_indef()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_help_all_indef()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_portal_all_indef()
self:assertProtectionCategoryEquals('
end
Line 683 ⟶ 714:
function suite:testCategory_edit_semi_talk_all_indef()
self:assertProtectionCategoryEquals('
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 indefinitely semi-protected pages', d.edit, d.semi, 0, nil, nil)
end
Line 728 ⟶ 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 indefinitely move-protected pages', d.move, d.full, 0, nil, nil)
end
Line 743 ⟶ 782:
function suite:testCategory_edit_semi_file_all_all()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_wikipedia_all_all()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_help_all_all()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_semi_portal_all_all()
self:assertProtectionCategoryEquals('
end
Line 767 ⟶ 806:
function suite:testCategory_edit_semi_talk_all_all()
self:assertProtectionCategoryEquals('
end
function suite:
self:assertProtectionCategoryEquals('Wikipedia semi-protected pages', d.edit, d.semi, 0, nil,
end
function suite:testCategory_edit_extended_main_all_all()
self:assertProtectionCategoryEquals('Wikipedia extended-confirmed-protected pages', 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('
end
function suite:testCategory_edit_full_wikipedia_all_all()
self:assertProtectionCategoryEquals('
end
function suite:testCategory_edit_full_help_all_all()
self:assertProtectionCategoryEquals('
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('
end
function suite:testCategory_edit_full_main_all_all()
self:assertProtectionCategoryEquals('Wikipedia fully protected pages', d.edit, d.full, 0, nil, nil)
end
Line 854 ⟶ 897:
end
function suite:
self:assertProtectionCategoryEquals('Wikipedia move-protected pages', d.move, d.full, 0, nil,
end
function suite:testCategory_move_extended_main_all_all()
self:assertProtectionCategoryEquals('Wikipedia extended-confirmed-protected pages', d.move, d.extended, 0, nil, nil)
end
function suite:testCategory_move_extended_template_all_all()
self:assertProtectionCategoryEquals('Wikipedia extended-confirmed-protected templates', d.move, d.extended, 10, nil, nil)
end
Line 895 ⟶ 946:
function suite:testCategory_pc_pc1_user_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages
end
function suite:testCategory_pc_pc1_usertalk_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages
end
function suite:testCategory_pc_pc1_file_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages
end
function suite:testCategory_pc_pc1_wikipedia_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages
end
function suite:testCategory_pc_pc1_help_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages
end
function suite:testCategory_pc_pc1_portal_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages
end
function suite:testCategory_pc_pc1_template_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages
end
function suite:testCategory_pc_pc1_category_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages
end
function suite:testCategory_pc_pc1_talk_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages
end
function suite:testCategory_pc_pc1_main_all_all()
self:assertProtectionCategoryEquals('Wikipedia pending changes protected pages
end
|