Jump to content

Module:Commons link/testcases

From Wikipedia, the free encyclopedia
localp=require('Module:UnitTests')functionp:testGallery()-- known linkself:preprocess_equals('{{#invoke:Commons link| getGallery | Mount Whitney}}','[[Commons:Mount Whitney|Mount Whitney]]')-- known link with linktextself:preprocess_equals('{{#invoke:Commons link| getGallery | Mount Whitney |linktext=Big Mountain}}','[[Commons:Mount Whitney|Big Mountain]]')-- forced searchself:preprocess_equals('{{#invoke:Commons link| getGallery | search=Mount Whitney}}','[[Commons:Special:Search/Mount Whitney|Mount Whitney]]')-- forced search + linktextself:preprocess_equals('{{#invoke:Commons link| getGallery | search=Mount Whitney |linktext=Big Mountain}}','[[Commons:Special:Search/Mount Whitney|Big Mountain]]')-- P935 matches sitelinkself:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q2217963}}','[[Commons:Samuel Baker House|Samuel Baker House]]')-- P935 matches sitelink + linktextself:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q2217963 |linktext=Big House}}','[[Commons:Samuel Baker House|Big House]]')-- sitelink only, lcfirstself:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q816044 | lcfirst=1}}','[[Commons:Bellows Falls, Vermont|bellows Falls, Vermont]]')-- sitelink only, boldself:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q816044 | bold=1}}','[[Commons:Bellows Falls, Vermont|<span style="font-weight:bold;">Bellows Falls, Vermont</span>]]')-- sitelink only, italicself:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q816044 | italic=1}}','[[Commons:Bellows Falls, Vermont|<span style="font-style:italic;">Bellows Falls, Vermont</span>]]')-- sitelink only, nowrapself:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q816044 | nowrap=1}}','[[Commons:Bellows Falls, Vermont|<span style="white-space:nowrap;">Bellows Falls, Vermont</span>]]')-- sitelink + linktextself:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q816044|linktext=Little Town}}','[[Commons:Bellows Falls, Vermont|Little Town]]')-- sitelink and P935 inconsistentself:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q139289}}','[[Commons:Special:Search/Boeing 737 MAX|Boeing 737 MAX]]')-- sitelink and P935 inconsistent + linktextself:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q139289|linktext=Not a plane}}','[[Commons:Special:Search/Boeing 737 MAX|Not a plane]]')-- no sitelink or P935self:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q29017978}}','[[Commons:Special:Search/Bell FCX-001|Bell FCX-001]]')-- no sitelink or P935, but linktextself:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q29017978|linktext=Medium Helicopter}}','[[Commons:Special:Search/Bell FCX-001|Medium Helicopter]]')endfunctionp:testCategory()-- known linkself:preprocess_equals('{{#invoke:Commons link| getCategory | Mount Whitney}}','[[Commons:Category:Mount Whitney|Mount Whitney]]')-- known link with linktextself:preprocess_equals('{{#invoke:Commons link| getCategory | Mount Whitney |linktext=Big Mountain}}','[[Commons:Category:Mount Whitney|Big Mountain]]')-- forced searchself:preprocess_equals('{{#invoke:Commons link| getCategory | search=Mount Whitney}}','[[Commons:Special:Search/Category:Mount Whitney|Mount Whitney]]')-- forced search + linktextself:preprocess_equals('{{#invoke:Commons link| getCategory | search=Mount Whitney |linktext=Big Mountain}}','[[Commons:Special:Search/Category:Mount Whitney|Big Mountain]]')-- P373 matches sitelink + lcfirstself:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2601154|lcfirst=1}}','[[Commons:Category:Agama lionotus|agama lionotus]]')-- boldself:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2601154|bold=1}}','[[Commons:Category:Agama lionotus|<span style="font-weight:bold;">Agama lionotus</span>]]')-- italicself:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2601154|italic=1}}','[[Commons:Category:Agama lionotus|<span style="font-style:italic;">Agama lionotus</span>]]')-- nowrapself:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2601154|nowrap=1}}','[[Commons:Category:Agama lionotus|<span style="white-space:nowrap;">Agama lionotus</span>]]')-- P373 matches sitelink + linktextself:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2601154|linktext=Small Lizard|lcfirst=1}}','[[Commons:Category:Agama lionotus|small Lizard]]')-- P910 matches P373self:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q853037}}','[[Commons:Category:Bánhida|Bánhida]]')-- P910 matches P373 + linktextself:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q853037|linktext=Old Neighborhood}}','[[Commons:Category:Bánhida|Old Neighborhood]]')-- P1754 matches P373self:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2551907}}','[[Commons:Category:Lakes of Turkey|Lakes of Turkey]]')-- P1754 matches P373 + linktextself:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2551907|linktext=Turkey Lakes}}','[[Commons:Category:Lakes of Turkey|Turkey Lakes]]')-- inconsistency between P373 and P1754self:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q1002229}}','[[Commons:Category:Municipality of Vipava|Municipality of Vipava]]')-- test fallbackself:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q21032720 |fallback=Boing}}','[[Commons:Special:Search/Category:Boing|Boing]]')-- inconsistency between P373 and P1754 + linktextself:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q1002229|linktext=Little Town}}','[[Commons:Category:Municipality of Vipava|Little Town]]')-- missing dataself:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2963317}}','[[Commons:Special:Search/Category:Chicago Lawn, Chicago|Chicago Lawn, Chicago]]')-- missing data + linktextself:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2963317|linktext=Big Neighborhood}}','[[Commons:Special:Search/Category:Chicago Lawn, Chicago|Big Neighborhood]]')endfunctionp:testGalleryOrCategory()-- known linkself:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | Mount Whitney}}','[[Commons:Mount Whitney|Mount Whitney]]')-- known link with linktextself:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | Mount Whitney |linktext=Big Mountain}}','[[Commons:Mount Whitney|Big Mountain]]')-- forced searchself:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | search=Mount Whitney}}','[[Commons:Special:Search/Mount Whitney|Mount Whitney]]')-- forced search + linktextself:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | search=Mount Whitney |linktext=Big Mountain}}','[[Commons:Special:Search/Mount Whitney|Big Mountain]]')-- P935 matches sitelinkself:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | qid=Q2217963}}','[[Commons:Samuel Baker House|Samuel Baker House]]')-- sitelink onlyself:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | qid=Q816044}}','[[Commons:Bellows Falls, Vermont|Bellows Falls, Vermont]]')-- inconsistent data, fall back to searchself:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | qid=Q21032720}}','[[Commons:Special:Search/Russian intervention in the Syrian civil war|Russian intervention in the Syrian civil war]]')-- P373 matches sitelinkself:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | qid=Q2601154}}','[[Commons:Category:Agama lionotus|Agama lionotus]]')-- P910 matches P373self:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | qid=Q853037}}','[[Commons:Category:Bánhida|Bánhida]]')-- P1754 matches P373self:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | qid=Q2551907}}','[[Commons:Category:Lakes of Turkey|Lakes of Turkey]]')-- missing gallery, inconsistent categoryself:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | qid=Q1002229}}','[[Commons:Category:Municipality of Vipava|Municipality of Vipava]]')-- test fallbackself:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | fallback=Boing | qid=Q21032720}}','[[Commons:Special:Search/Boing|Boing]]')-- missing dataself:preprocess_equals('{{#invoke:Commons link| getGalleryOrCategory | qid=Q2963317}}','[[Commons:Special:Search/Chicago Lawn, Chicago|Chicago Lawn, Chicago]]')endfunctionp:testHasGallery()-- P935 matches sitelinkself:preprocess_equals('{{#invoke:Commons link| hasGallery | qid=Q2217963}}','Samuel Baker House')-- sitelink onlyself:preprocess_equals('{{#invoke:Commons link| hasGallery | qid=Q816044}}','Bellows Falls, Vermont')-- sitelink and P935 inconsistentself:preprocess_equals('{{#invoke:Commons link| hasGallery | qid=Q139289}}','')-- no sitelink or P935 or categoryself:preprocess_equals('{{#invoke:Commons link| hasGallery | qid=Q29017978}}','')-- P373 matches sitelinkself:preprocess_equals('{{#invoke:Commons link| hasGallery | qid=Q2601154}}','')-- P910 matches P373self:preprocess_equals('{{#invoke:Commons link| hasGallery | qid=Q853037}}','')-- P1754 matches P373self:preprocess_equals('{{#invoke:Commons link| hasGallery | qid=Q2551907}}','')-- missing gallery, inconsistent categoryself:preprocess_equals('{{#invoke:Commons link| hasGallery | qid=Q1002229}}','')-- missing dataself:preprocess_equals('{{#invoke:Commons link| hasGallery | qid=Q2963317}}','')endfunctionp:testHasCategory()-- sitelink onlyself:preprocess_equals('{{#invoke:Commons link| hasCategory | qid=Q816044}}','Category:Bellows Falls, Vermont')-- sitelink and P935 inconsistent, fallback to Category insteadself:preprocess_equals('{{#invoke:Commons link| hasCategory | qid=Q139289}}','Category:Boeing 737 MAX')-- P373 matches sitelinkself:preprocess_equals('{{#invoke:Commons link| hasCategory | qid=Q2601154}}','Category:Agama lionotus')-- P910 matches P373self:preprocess_equals('{{#invoke:Commons link| hasCategory | qid=Q853037}}','Category:Bánhida')-- P1754 matches P373self:preprocess_equals('{{#invoke:Commons link| hasCategory | qid=Q2551907}}','Category:Lakes of Turkey')-- missing gallery, inconsistent categoryself:preprocess_equals('{{#invoke:Commons link| hasCategory | qid=Q1002229}}','Category:Municipality of Vipava')-- missing dataself:preprocess_equals('{{#invoke:Commons link| hasCategory | qid=Q2963317}}','')endfunctionp:testHasGalleryOrCategory()-- P935 matches sitelinkself:preprocess_equals('{{#invoke:Commons link| hasGalleryOrCategory | qid=Q2217963}}','Samuel Baker House')-- sitelink onlyself:preprocess_equals('{{#invoke:Commons link| hasGalleryOrCategory | qid=Q816044}}','Bellows Falls, Vermont')-- sitelink and P935 inconsistentself:preprocess_equals('{{#invoke:Commons link| hasGalleryOrCategory | qid=Q139289}}','Category:Boeing 737 MAX')-- P373 matches sitelinkself:preprocess_equals('{{#invoke:Commons link| hasGalleryOrCategory | qid=Q2601154}}','Category:Agama lionotus')-- P910 matches P373self:preprocess_equals('{{#invoke:Commons link| hasGalleryOrCategory | qid=Q853037}}','Category:Bánhida')-- P1754 matches P373self:preprocess_equals('{{#invoke:Commons link| hasGalleryOrCategory | qid=Q2551907}}','Category:Lakes of Turkey')-- missing galleryself:preprocess_equals('{{#invoke:Commons link| hasGalleryOrCategory | qid=Q1002229}}','Category:Municipality of Vipava')-- missing dataself:preprocess_equals('{{#invoke:Commons link| hasGalleryOrCategory | qid=Q2963317}}','')-- another testself:preprocess_equals('{{#invoke:Commons link| hasGalleryOrCategory | qid=Q185676}}','Category:Fado')endfunctionp:testGalleryAndCategory()-- known linkself:preprocess_equals('{{#invoke:Commons link| getGalleryAndCategory | Mount Whitney}}','[[Commons:Mount Whitney|Mount Whitney]]')-- known link with linktextself:preprocess_equals('{{#invoke:Commons link| getGalleryAndCategory | Mount Whitney |linktext=Big Mountain | italic=1}}','[[Commons:Mount Whitney|<span style="font-style:italic;">Big Mountain</span>]]')-- known categoryself:preprocess_equals('{{#invoke:Commons link| getGalleryAndCategory | | Mount Whitney | bold=1}}','[[Commons:Category:Mount Whitney|<span style="font-weight:bold;">Mount Whitney</span>]]')-- known category with categorytextself:preprocess_equals('{{#invoke:Commons link| getGalleryAndCategory | | Mount Whitney |linktext=Big Mountain|bold=1|italic=1}}','[[Commons:Category:Mount Whitney|<span style="font-style:italic; font-weight:bold;">Big Mountain</span>]]')-- known link and categoryself:preprocess_equals('{{#invoke:Commons link| getGalleryAndCategory | Mount Whitney | Mount Whitney}}','[[Commons:Mount Whitney|Mount Whitney]] ([[Commons:Category:Mount Whitney|category]])')-- known link and category with linktextself:preprocess_equals('{{#invoke:Commons link| getGalleryAndCategory | Mount Whitney | Mount Whitney | linktext=Big Mountain|bold=1|italic=1}}','[[Commons:Mount Whitney|<span style="font-style:italic; font-weight:bold;">Big Mountain</span>]] ([[Commons:Category:Mount Whitney|category]])')-- both gallery and category existself:preprocess_equals('{{#invoke:Commons link| getGalleryAndCategory | qid=Q816044|bold=1|categoryText=cat}}','[[Commons:Bellows Falls, Vermont|<span style="font-weight:bold;">Bellows Falls, Vermont</span>]] ([[Commons:Category:Bellows Falls, Vermont|cat]])')-- P373 matches sitelink, category onlyself:preprocess_equals('{{#invoke:Commons link| getGalleryAndCategory | qid=Q2601154|bold=1}}','[[Commons:Category:Agama lionotus|<span style="font-weight:bold;">Agama lionotus</span>]]')-- P910 matches P373, category onlyself:preprocess_equals('{{#invoke:Commons link| getGalleryAndCategory | qid=Q853037|italic=1|bold=1}}','[[Commons:Category:Bánhida|<span style="font-style:italic; font-weight:bold;">Bánhida</span>]]')-- P1754 matches P373, category onlyself:preprocess_equals('{{#invoke:Commons link| getGalleryAndCategory | qid=Q2551907}}','[[Commons:Category:Lakes of Turkey|Lakes of Turkey]]')-- missing dataself:preprocess_equals('{{#invoke:Commons link| getGalleryAndCategory | qid=Q2963317|bold=1|linktext=Chicago Lawn|oneSearch=1}}','[[Commons:Special:Search/Chicago Lawn, Chicago|<span style="font-weight:bold;">Chicago Lawn</span>]]')endfunctionp:testTitleQID()self:preprocess_equals('{{#invoke:Commons link| getTitleQID }}','Commons link/testcases,Module talk,nil')self:preprocess_equals('{{#invoke:Commons link| getTitleQID | Q42 | 1}}','Douglas Adams,,Q42')self:preprocess_equals('{{#invoke:Commons link| getTitleQID | Q15048757 | 1}}','Python (genus),Category,Q15048757')-- no page corresponding to QIDself:preprocess_equals('{{#invoke:Commons link| getTitleQID | Q0}}',',Module talk,Q0')-- QID doesn't link back to enself:preprocess_equals('{{#invoke:Commons link| getTitleQID | Q68979196 | 1}}',',,Q68979196')-- gibberish QIDself:preprocess_equals('{{#invoke:Commons link| getTitleQID | 1234}}','Commons link/testcases,Module talk,nil')endfunctionp:testLookupFallback()-- P910 doesn't existself:preprocess_equals('{{#invoke:Commons link| lookupFallback | Q2217963 | P910}}','nil')-- normal P910self:preprocess_equals('{{#invoke:Commons link| lookupFallback | Q853037 | P910}}','Bánhida')-- normal P1754self:preprocess_equals('{{#invoke:Commons link| lookupFallback | Q2551907 | P1754}}','Lakes of Turkey')-- gibberish prop stringself:preprocess_equals('{{#invoke:Commons link| lookupFallback | Q2551907 | xyzzy}}','nil')endfunctionp:testTracking()localgalPrefix='[[Category:Commons link 'localcatPrefix='[[Category:Commons category link 'localonWikidata='is on Wikidata]]'localdefinedAsPagename='is defined as the pagename]]'locallocallyDefined='is locally defined]]'localfromWikidata='from Wikidata]]'localisPagename='is the pagename]]'localgalInconsistent='[[Category:Inconsistent wikidata for Commons gallery]]'localcatInconsistent='[[Category:Inconsistent wikidata for Commons category]]'-- default gallery is specified and is Commons gallery on wikidataself:preprocess_equals('{{#invoke:Commons link| tracking | Samuel Baker House | fetchGallery = 1 | fetchCategory = 1 | qid=Q2217963}}',galPrefix..onWikidata,{nowiki=1})-- default gallery is specified and is Commons category on wikidataself:preprocess_equals('{{#invoke:Commons link| tracking | Fado | fetchGallery=1 | fetchCategory=1 | qid=Q185676}}',galPrefix..definedAsPagename,{nowiki=1})-- default category is specified and is Commons category on wikidataself:preprocess_equals('{{#invoke:Commons link| tracking | Category:Fado | fetchCategory=1 | qid=Q8442543}}',catPrefix..onWikidata,{nowiki=1})-- inconsistent wikidata returns nil, so doesn't match title. Called from Template:Commonsself:preprocess_equals('{{#invoke:Commons link| tracking | Municipality of Vipava | fetchGallery=1 | fetchCategory=1 | qid=Q1002229}}',galPrefix..definedAsPagename,{nowiki=1})-- Default string is not the same as either title or wikidata. Called from Template:Commonsself:preprocess_equals('{{#invoke:Commons link| tracking | Bellows Falls | fetchGallery = 1 | fetchCategory=1 | qid=Q816044}}',galPrefix..locallyDefined,{nowiki=1})-- Default string is not the same as either title or wikidata. Called from Template:Commonscatself:preprocess_equals('{{#invoke:Commons link| tracking | Category:Bellows Falls | fetchCategory=1 | qid=Q816044}}',catPrefix..locallyDefined,{nowiki=1})-- No string. Commons gallery on Wikidataself:preprocess_equals('{{#invoke:Commons link| tracking || fetchGallery=1 | fetchCategory=1 | qid=Q235539}}',galPrefix..fromWikidata,{nowiki=1})-- No string. Commons category on Wikidataself:preprocess_equals('{{#invoke:Commons link| tracking || fetchCategory=1 | qid=Q121319}}',catPrefix..fromWikidata,{nowiki=1})-- No string. Nothing on Wikidata. Called from Template:Commonsself:preprocess_equals('{{#invoke:Commons link| tracking | fetchGallery=1| fetchCategory=1 | qid=Q2963317}}',galPrefix..isPagename,{nowiki=1})-- No string. Nothing on Wikidata. Called from Template:CommonsCatself:preprocess_equals('{{#invoke:Commons link| tracking || fetchCategory=1 | qid=Q2963317}}',catPrefix..isPagename,{nowiki=1})-- Inconsistent wikidata for categoryself:preprocess_equals('{{#invoke:Commons link| tracking |fetchCategory=1|qid=Q21032720}}',catInconsistent,{nowiki=1})endreturnp
close