Module:GetShortDescription/testcases: Difference between revisions

Content deleted Content added
this is more work that writing the module in the first place
saving in incomplete state due to need to shut computer down
Line 1:
-- Unit tests for [[Module:{{ROOTPAGENAME}}]]. Run tests on the talk page.
-- Due to the nature of short descriptions; some of these tests may need to be updated before running them.
 
local p = require('Module:UnitTests')
Line 32:
end
 
function p:only_wikidataonly_wikidata__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=The PartisanExample|only=wikidata}}', "song composed by Anna Marly with lyrics by Emmanuel d'Astier de La Vigerie performed byWikimedia Leonarddisambiguation Cohenpage")
end
 
function p:prefer_explicit__explicit_existsonly_wikidata__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=TheUser:Fred PartisanGandt/sandbox/explicit short description|preferonly=explicitwikidata}}', "1943 song by Anna Marly and Emmanuel d'Astier, popularised by Leonard Cohen in 1969")
end
 
function p:prefer_explicit__explicit_does_not_existprefer_explicit__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author, Author (Star Trek: Voyager)Wikipedia|prefer=explicit}}', "episodeFree ofmultilingual, Star Trek: Voyageronline, (S7crowdsourced E20)encyclopedia")
end
 
function p:prefer_explicit__explicit_exists__wikidata_does_not_exist()
function p:prefer_wikidata__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=TheUser:Fred PartisanGandt/sandbox/explicit short description|prefer=wikidataexplicit}}', "song composed by Anna Marly with lyrics by Emmanuel d'Astier de La Vigerie performed byexplicit Leonardshort Cohendescription")
end
 
function p:prefer_explicit__explicit_does_not_exist__wikidata_exists()
function p:prefer_wikidata__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author, Author (Star Trek: Voyager)Example|prefer=wikidataexplicit}}', "episode of Star Trek: VoyagerWikimedia (S7disambiguation E20)page")
end
 
function p:prefer_wikidata__wikidata_exists__explicit_exists()
function p:conflicting__only_explicit_prefer_wikidata__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=The PartisanWikipedia|prefer=wikidata|only=explicit}}', "1943Free songmultilingual, by Anna Marly and Emmanuel d'Astieronline, popularised by Leonard Cohen incrowdsourced 1969encyclopedia")
end
 
function p:prefer_wikidata__wikidata_exists__explicit_does_not_exist()
function p:conflicting__only_wikidata_prefer_explicit__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=The PartisanExample|prefer=explicit|only=wikidata}}', "song composed by Anna Marly with lyrics by Emmanuel d'Astier de La Vigerie performed byWikimedia Leonarddisambiguation Cohenpage")
end
 
------------------------
function p:conflicting__only_explicit_prefer_wikidata__explicit_does_not_exist()
 
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author, Author (Star Trek: Voyager)|prefer=wikidata|only=explicit}}', "")
function p:fallback__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=User:Fred Gandt/sandbox/explicit short description}}', "explicit short description")
end
 
function p:fallback__explicit_exists__wikidata_does_not_exist()
function p:conflicting__only_wikidata_prefer_explicit__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author,User:Fred AuthorGandt/sandbox/explicit (Starshort Trek: Voyager)|prefer=explicit|only=wikidatadescription}}', "episode of Star Trek: Voyagerexplicit (S7short E20)description")
end
 
function p:only_explict_fallback__explicit_existsfallback__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals("'{{#invoke:GetShortDescription|main|name=The Partisan|only=explicit|fallback=a song by Anna Marly and Emmanuel d'AstierExample}}"', "1943 song by Anna Marly and Emmanuel d'Astier, popularised by Leonard CohenWikimedia indisambiguation 1969page")
end
 
function p:fallback__explicit_does_not_exist__wikidata_does_not_exist()
function p:only_explict_fallback__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author,User:Fred AuthorGandt/sandbox/no (Star Trek: Voyager)|only=explicit|fallback=an episodeshort of Star Trek: Voyagerdescription}}', "an episode of Star Trek: Voyager")
end
 
function p:only_explicit__fallback__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=User:Fred Gandt/sandbox/explicit short description|only=explicit}}', "explicit short description")
end
 
function p:only_explict__fallback__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=User:Fred Gandt/sandbox/no explicit short description|only=explicit}}', "")
end
 
function p:only_wikidata__fallback__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Example|only=wikidata}}', "Wikimedia disambiguation page")
end
 
function p:only_wikidata__fallback__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=User:Fred Gandt/sandbox/explicit short description|only=wikidata}}', "")
end
 
function p:prefer_explicit__fallback__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Wikipedia|prefer=explicit}}', "Free multilingual, online, crowdsourced encyclopedia")
end
 
function p:prefer_explicit__fallback__explicit_exists__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=User:Fred Gandt/sandbox/explicit short description|prefer=explicit}}', "explicit short description")
end
 
function p:prefer_explicit__fallback__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Example|prefer=explicit}}', "Wikimedia disambiguation page")
end
 
function p:prefer_wikidata__fallback__wikidata_exists__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Wikipedia|prefer=wikidata}}', "Free multilingual, online, crowdsourced encyclopedia")
end
 
function p:prefer_wikidata__fallback__wikidata_exists__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Example|prefer=wikidata}}', "Wikimedia disambiguation page")
end
 
------------------------
 
function p:conflicting__only_explicit__prefer_wikidata__explicit_exists__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=User:Fred Gandt/sandbox/explicit short description|prefer=wikidata|only=explicit}}', "explicit short description")
end
 
function p:conflicting__only_wikidata__prefer_explicit__wikidata_exists__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Example|prefer=explicit|only=wikidata}}', "Wikimedia disambiguation page")
end
 
function p:conflicting__only_explicit__prefer_wikidata__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author, Author (Star Trek: Voyager)Example|prefer=wikidata|only=explicit}}', "")
end
 
--[[ we would need something on Wikidata with no description to test these
 
function p:prefer_explicit__explicit_does_not_exist__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Example|prefer=explicit}}', "")
end
 
function p:prefer_wikidata__wikidata_does_not_exist__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Example|prefer=wikidata}}', "")
end
 
function p:prefer_wikidata__wikidata_does_not_exist__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Example|prefer=wikidata}}', "")
end
 
function p:conflicting__only_wikidata__prefer_explicit__wikidata_does_not_exist__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Example|prefer=explicit|only=wikidata}}', "")
end
 
]]
 
-- Testing |lang_italic= |lang_nocat= |lang_size= |lang_cat= |lang_rtl= |lang_no= will require a wikidata description in a language other than English to be returned