def test_redirect_normalization(self): """Test that a page redirect loads correctly with or without a query normalization""" capital_party = wikia.page("Communist Party") lower_party = wikia.page("communist Party") self.assertIsInstance(capital_party, wikia.WikiaPage) self.assertIsInstance(lower_party, wikia.WikiaPage) self.assertEqual(capital_party.title, "Communist party") self.assertEqual(capital_party, lower_party)
def test_redirect_true(self): """Test that a page successfully redirects a query.""" # no error should be raised if redirect is test_redirect_true mp = wikia.page("Menlo Park, New Jersey") self.assertEqual(mp.title, "Edison, New Jersey") self.assertEqual(mp.url, "http://en.wikia.org/wiki/Edison,_New_Jersey")
async def info(self, ctx, *arg1): member = ctx.author arg1 = ' '.join(arg1) searchword = arg1.title() mb = wikia.page("dancingline", str(searchword)) embed = discord.Embed(title=mb.title, description=mb.content, url=mb.url, colour=member.colour) embed.set_author(icon_url=member.avatar_url, name=str(member)) embed.set_footer(text=self.bot.user.name, icon_url=self.bot.user.avatar_url) embed.set_thumbnail(url=ctx.guild.icon_url) if mb.images == []: pass else: embed.set_image(url=mb.images[0]) await ctx.send(content=None, embed=embed)
def test_from_page_id(self): """Test loading from a page id""" self.assertEqual(self.celtuce, wikia.page(pageid=1868108))
def setUp(self): # shortest wikia articles with images and sections self.celtuce = wikia.page("Celtuce") self.cyclone = wikia.page("Tropical Depression Ten (2005)") self.great_wall_of_china = wikia.page("Great Wall of China")
def test_redirect_with_normalization(self): """Test that a page redirect with a normalized query loads correctly""" the_party = wikia.page("communist Party") self.assertIsInstance(the_party, wikia.WikiaPage) self.assertEqual(the_party.title, "Communist party")
def test_redirect_false(self): """Test that page raises an error on a redirect when redirect == False.""" mp = lambda: wikia.page("Menlo Park, New Jersey", redirect=False) self.assertRaises(wikia.RedirectError, mp)
def get_summary(sub_wikia, title): page = wikia.page(sub_wikia, title) return page.section(page.sections[0])
def test_missing(self): """Test that page raises a PageError for a nonexistant page.""" # Callicarpa? purpleberry = lambda: wikia.page("purpleberry") self.assertRaises(wikia.PageError, purpleberry)
from wikia import wikia mb = wikia.page("Runescape", "Castle Drakan") print(mb.title) print(mb.url)