Module:Fiction redirect category handler/testcases

-- Unit tests for Module:Fiction redirect category handler. Click talk page to run tests. local p = require('Module:UnitTests')

function p:test_01_1_redirect_categories_live self:preprocess_equals_many('', {		{"restricted=yes", "R from fictional character, R restricted, R to section, R with possibilities, R printworthy"},		{"birth_name=yes", "R from fictional character, R from birth name, R to section, R printworthy"},		{"alt_name=yes", "R from fictional character, R from alternative name, R to section, R printworthy"},		{"former_name=yes", "R from fictional character, R from former name, R to section, R printworthy"},		{"short_name=yes", "R from fictional character, R from short name, R to section, R printworthy"},		{"long_name=yes", "R from fictional character, R from long name, R to section, R printworthy"},		{"title_name=yes", "R from fictional character, R from name with title, R to section, R unprintworthy"},		{"alt_spelling=yes", "R from fictional character, R from alternative spelling, R to section, R unprintworthy"},		{"to_diacritic=yes", "R from fictional character, R to diacritic, R to section, R unprintworthy"}, {"incorrect_name=yes", "R from fictional character, R from incorrect name, R to section, R unprintworthy"}, {"capitalisation=yes", "R from fictional character, R from miscapitalisation, R to section, R unprintworthy"}, {"unneeded_dab=yes", "R from fictional character, R from unnecessary disambiguation, R to section, R unprintworthy"}, {"primary=yes", "R from fictional character, R to section, R avoided double redirect, R printworthy"}, {"merge=yes", "R from fictional character, R to section, R from merge, R with possibilities, R printworthy"}, {"history=yes", "R from fictional character, R to section, R with history, R with possibilities, R printworthy"}, {"draft_move=yes", "R from fictional character, R from move, R from drafts, R to section, R unprintworthy"}, }) end

function p:test_01_2_redirect_categories_sandbox self:preprocess_equals_many('', {		{"restricted=yes", "R from fictional character, R restricted, R to section, R with possibilities, R printworthy"},		{"birth_name=yes", "R from fictional character, R from birth name, R to section, R printworthy"},		{"alt_name=yes", "R from fictional character, R from alternative name, R to section, R printworthy"},		{"former_name=yes", "R from fictional character, R from former name, R to section, R printworthy"},		{"short_name=yes", "R from fictional character, R from short name, R to section, R printworthy"},		{"long_name=yes", "R from fictional character, R from long name, R to section, R printworthy"},		{"title_name=yes", "R from fictional character, R from name with title, R to section, R unprintworthy"},		{"alt_spelling=yes", "R from fictional character, R from alternative spelling, R to section, R unprintworthy"},		{"to_diacritic=yes", "R from fictional character, R to diacritic, R to section, R unprintworthy"}, {"incorrect_name=yes", "R from fictional character, R from incorrect name, R to section, R unprintworthy"}, {"capitalisation=yes", "R from fictional character, R from miscapitalisation, R to section, R unprintworthy"}, {"unneeded_dab=yes", "R from fictional character, R from unnecessary disambiguation, R to section, R unprintworthy"}, {"primary=yes", "R from fictional character, R to section, R avoided double redirect, R printworthy"}, {"merge=yes", "R from fictional character, R to section, R from merge, R with possibilities, R printworthy"}, {"history=yes", "R from fictional character, R to section, R with history, R with possibilities, R printworthy"}, {"draft_move=yes", "R from fictional character, R from move, R from drafts, R to section, R unprintworthy"}, }) end

function p:test_02_1_title_handling_live self:preprocess_equals_many('', {		{"test_title=Sawyer", "R from fictional character, R to section, R with possibilities, R printworthy"},		{"test_title=Sawyer (characteer)", "R from fictional character, R from incorrect disambiguation, R to section, R unprintworthy"},		{"test_title=Sawyer (Lost)|correct_disambiguation=Lost", "R from fictional character, R to section, R with possibilities, R printworthy"},		{"test_title=Sawyer (Lost character)|correct_disambiguation=Lost", "R from fictional character, R to section, R with possibilities, R printworthy"},	}) end

function p:test_02_2_character_title_handling_sandbox self:preprocess_equals_many('', {		{"test_title=Sawyer", "R from fictional character, R to section, R with possibilities, R printworthy"},		{"test_title=Sawyer (characteer)", "R from fictional character, R from incorrect disambiguation, R to section, R unprintworthy"},		{"test_title=Sawyer (Lost)|correct_disambiguation=Lost", "R from fictional character, R to section, R with possibilities, R printworthy"},		{"test_title=Sawyer (Lost character)|correct_disambiguation=Lost", "R from fictional character, R to section, R with possibilities, R printworthy"},	}) end

function p:test_03_1_element_title_handling_live self:preprocess_equals_many('', {				{"test_title=4 8 15 16 23 42", "R from fictional element, R to section, R with possibilities, R printworthy"},		{"test_title=4 8 15 16 23 42 (element)", "R from fictional element, R from incorrect disambiguation, R to section, R unprintworthy"},		{"test_title=4 8 15 16 23 42 (The Lost Numbers)", "R from fictional element, R from incorrect disambiguation, R to section, R unprintworthy"},		{"test_title=4 8 15 16 23 42 (Lost element)|correct_disambiguation=Lost", "R from fictional element, R to section, R with possibilities, R printworthy"},		{"test_title=4 8 15 16 23 42 (Lost)|correct_disambiguation=Lost", "R from fictional element, R to section, R with possibilities, R printworthy"},	}) end

function p:test_03_2_element_title_handling_sandbox self:preprocess_equals_many('', {				{"test_title=4 8 15 16 23 42", "R from fictional element, R to section, R with possibilities, R printworthy"},		{"test_title=4 8 15 16 23 42 (element)", "R from fictional element, R from incorrect disambiguation, R to section, R unprintworthy"},		{"test_title=4 8 15 16 23 42 (The Lost Numbers)", "R from fictional element, R from incorrect disambiguation, R to section, R unprintworthy"},		{"test_title=4 8 15 16 23 42 (Lost element)|correct_disambiguation=Lost", "R from fictional element, R to section, R with possibilities, R printworthy"},		{"test_title=4 8 15 16 23 42 (Lost)|correct_disambiguation=Lost", "R from fictional element, R to section, R with possibilities, R printworthy"},	}) end

function p:test_04_1_location_title_handling_live self:preprocess_equals_many('', {		{"test_title=The Swan", "R from fictional location, R to section, R with possibilities, R printworthy"},				{"test_title=The Swan (location)", "R from fictional location, R from incorrect disambiguation, R to section, R unprintworthy"},		{"test_title=The Swan (Lost)|correct_disambiguation=Lost", "R from fictional location, R to section, R with possibilities, R printworthy"},		{"test_title=The Swan (Lost location)|correct_disambiguation=Lost", "R from fictional location, R to section, R with possibilities, R printworthy"},	}) end

function p:test_04_2_location_title_handling_sandbox self:preprocess_equals_many('', {		{"test_title=The Swan", "R from fictional location, R to section, R with possibilities, R printworthy"},				{"test_title=The Swan (location)", "R from fictional location, R from incorrect disambiguation, R to section, R unprintworthy"},		{"test_title=The Swan (Lost)|correct_disambiguation=Lost", "R from fictional location, R to section, R with possibilities, R printworthy"},		{"test_title=The Swan (Lost location)|correct_disambiguation=Lost", "R from fictional location, R to section, R with possibilities, R printworthy"},	}) end

function p:test_05_1_title_section_handling_live self:preprocess_equals_many('', {		{"", "R from fictional character, R to section, R with possibilities, R printworthy"},		{"anchor=yes", "R from fictional character, R to anchor, R with possibilities, R printworthy"},		{"section=test", "R from fictional character, R to section, R with possibilities, R printworthy"},		{"list=test", "R from fictional character, R to list entry, R with possibilities, R printworthy"},		{"to_article=test", "R from fictional character, R with possibilities, R printworthy"},	}) end

function p:test_05_2_title_section_handling_sandbox self:preprocess_equals_many('', {		{"", "R from fictional character, R to section, R with possibilities, R printworthy"},		{"anchor=yes", "R from fictional character, R to anchor, R with possibilities, R printworthy"},		{"section=test", "R from fictional character, R to section, R with possibilities, R printworthy"},		{"list=test", "R from fictional character, R to list entry, R with possibilities, R printworthy"},		{"to_article=test", "R from fictional character, R with possibilities, R printworthy"},	}) end

function p:test_06_1_multi_series_live self:preprocess_equals_many('', {		{"series_name=Arrow (TV series)|series_name2=DC Extended Universe", "Arrow (TV series), DC Extended Universe, R from fictional character, R to section, R with possibilities, R printworthy"},		{"series_name=Arrow (TV series)|series_name2=DC Extended Universe|series_name3=The Flash (TV series)", "Arrow (TV series), DC Extended Universe, The Flash (TV series), R from fictional character, R to section, R with possibilities, R printworthy"},	}) end

function p:test_06_2_multi_series_sandbox self:preprocess_equals_many('', {		{"series_name=Arrow (TV series)|series_name2=DC Extended Universe", "Arrow (TV series), DC Extended Universe, R from fictional character, R to section, R with possibilities, R printworthy"},		{"series_name=Arrow (TV series)|series_name2=DC Extended Universe|series_name3=The Flash (TV series)", "Arrow (TV series), DC Extended Universe, The Flash (TV series), R from fictional character, R to section, R with possibilities, R printworthy"},	}) end

return p