Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Hike395/CommonsLink2/testcases
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = require('Module:UnitTests') function p:testGallery() -- known link self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | Mount Whitney}}', '[[Commons:Mount Whitney|Mount Whitney]]') -- known link with linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | Mount Whitney |linktext=Big Mountain}}', '[[Commons:Mount Whitney|Big Mountain]]') -- forced search self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | search=Mount Whitney}}', '[[Commons:Special:Search/Mount Whitney|Mount Whitney]]') -- forced search + linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | search=Mount Whitney |linktext=Big Mountain}}', '[[Commons:Special:Search/Mount Whitney|Big Mountain]]') -- P935 matches sitelink self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | qid=Q2217963}}', '[[Commons:Samuel Baker House|Samuel Baker House]]') -- P935 matches sitelink + linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | qid=Q2217963 |linktext=Big House}}', '[[Commons:Samuel Baker House|Big House]]') -- sitelink only self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | qid=Q816044}}', '[[Commons:Bellows Falls, Vermont|Bellows Falls, Vermont]]') -- sitelink + linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | qid=Q816044|linktext=Little Town}}', '[[Commons:Bellows Falls, Vermont|Little Town]]') -- sitelink and P935 inconsistent self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | qid=Q139289}}', '[[Commons:Special:Search/Boeing 737 MAX|Boeing 737 MAX]]') -- sitelink and P935 inconsistent + linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | qid=Q139289|linktext=Not a plane}}', '[[Commons:Special:Search/Boeing 737 MAX|Not a plane]]') -- no sitelink or P935 self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | qid=Q29017978}}', '[[Commons:Special:Search/Bell FCX-001|Bell FCX-001]]') -- no sitelink or P935, but linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGallery | qid=Q29017978|linktext=Medium Helicopter}}', '[[Commons:Special:Search/Bell FCX-001|Medium Helicopter]]') end function p:testCategory() -- known link self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | Mount Whitney}}', '[[Commons:Category:Mount Whitney|Mount Whitney]]') -- known link with linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | Mount Whitney |linktext=Big Mountain}}', '[[Commons:Category:Mount Whitney|Big Mountain]]') -- forced search self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | search=Mount Whitney}}', '[[Commons:Special:Search/Category:Mount Whitney|Mount Whitney]]') -- forced search + linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | search=Mount Whitney |linktext=Big Mountain}}', '[[Commons:Special:Search/Category:Mount Whitney|Big Mountain]]') -- P373 matches sitelink self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | qid=Q2601154}}', '[[Commons:Category:Agama lionotus|Agama lionotus]]') -- P373 matches sitelink + linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | qid=Q2601154|linktext=Small Lizard}}', '[[Commons:Category:Agama lionotus|Small Lizard]]') -- P910 matches P373 self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | qid=Q853037}}', '[[Commons:Category:Bánhida|Bánhida]]') -- P910 matches P373 + linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | qid=Q853037|linktext=Old Neighborhood}}', '[[Commons:Category:Bánhida|Old Neighborhood]]') -- P1754 matches P373 self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | qid=Q2551907}}', '[[Commons:Category:Lakes of Turkey|Lakes of Turkey]]') -- P1754 matches P373 + linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | qid=Q2551907|linktext=Turkey Lakes}}', '[[Commons:Category:Lakes of Turkey|Turkey Lakes]]') -- inconsistency between P373 and P1754 self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | qid=Q1002229}}', '[[Commons:Special:Search/Category:Municipality of Vipava|Municipality of Vipava]]') -- inconsistency between P373 and P1754 + linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | qid=Q1002229|linktext=Little Town}}', '[[Commons:Special:Search/Category:Municipality of Vipava|Little Town]]') -- missing data self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | qid=Q2963317}}', '[[Commons:Special:Search/Category:Chicago Lawn, Chicago|Chicago Lawn, Chicago]]') -- missing data + linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getCategory | qid=Q2963317|linktext=Big Neighborhood}}', '[[Commons:Special:Search/Category:Chicago Lawn, Chicago|Big Neighborhood]]') end function p:testGalleryOrCategory() -- known link self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | Mount Whitney}}', '[[Commons:Mount Whitney|Mount Whitney]]') -- known link with linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | Mount Whitney |linktext=Big Mountain}}', '[[Commons:Mount Whitney|Big Mountain]]') -- forced search self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | search=Mount Whitney}}', '[[Commons:Special:Search/Mount Whitney|Mount Whitney]]') -- forced search + linktext self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | search=Mount Whitney |linktext=Big Mountain}}', '[[Commons:Special:Search/Mount Whitney|Big Mountain]]') -- P935 matches sitelink self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | qid=Q2217963}}', '[[Commons:Samuel Baker House|Samuel Baker House]]') -- sitelink only self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | qid=Q816044}}', '[[Commons:Bellows Falls, Vermont|Bellows Falls, Vermont]]') -- sitelink and P935 inconsistent, fallback to Category instead self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | qid=Q139289}}', '[[Commons:Category:Boeing 737 MAX|Boeing 737 MAX]]') -- no sitelink or P935 or category self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | qid=Q29017978}}', '[[Commons:Special:Search/Bell FCX-001|Bell FCX-001]]') -- P373 matches sitelink self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | qid=Q2601154}}', '[[Commons:Category:Agama lionotus|Agama lionotus]]') -- P910 matches P373 self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | qid=Q853037}}', '[[Commons:Category:Bánhida|Bánhida]]') -- P1754 matches P373 self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | qid=Q2551907}}', '[[Commons:Category:Lakes of Turkey|Lakes of Turkey]]') -- missing gallery, inconsistent category self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | qid=Q1002229}}', '[[Commons:Special:Search/Municipality of Vipava|Municipality of Vipava]]') -- missing data self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getGalleryOrCategory | qid=Q2963317}}', '[[Commons:Special:Search/Chicago Lawn, Chicago|Chicago Lawn, Chicago]]') end function p:testTitleQID() self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getTitleQID }}','Sandbox/Hike395/CommonsLink2/testcases,829,nil') self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getTitleQID | Q42}}','Douglas Adams,829,Q42') self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| getTitleQID | Q15048757}}','Python,829,Q15048757') end function p:testLookupFallback() -- P910 doesn't exist self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| lookupFallback | Q2217963 | P910}}','nil') -- P910 exists, but isn't a category self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| lookupFallback | Q3495319 | P910}}','nil') -- normal P910 self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| lookupFallback | Q853037 | P910}}','Bánhida') -- normal P1754 self:preprocess_equals('{{#invoke:Sandbox/Hike395/CommonsLink2| lookupFallback | Q2551907 | P1754}}','Lakes of Turkey') end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Hike395/CommonsLink2/testcases/doc
(
edit
)