jenkins-bot has submitted this change and it was merged.
Change subject: Unit tests for Site.{long,short,ancient,unwatched}pages() ......................................................................
Unit tests for Site.{long,short,ancient,unwatched}pages()
More unit tests for uncovered Site functions.
Bug: T60941 Change-Id: I7a7ee263b56c4cab8c73ae5db701dc595de562e8 --- M tests/site_tests.py 1 file changed, 47 insertions(+), 0 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve Mpaa: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py index d2cfcd1..9ec0b45 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -738,6 +738,53 @@ self.assertTrue(all(isinstance(tup[2], unicode) for tup in the_list)) self.assertTrue(all(isinstance(tup[3], unicode) for tup in the_list))
+ def test_longpages(self): + """Test the site.longpages() method.""" + mysite = self.get_site() + longpages = list(mysite.longpages(total=10)) + + # Make sure each object returned by site.longpages() is + # a tuple of a Page object and an int + self.assertTrue(all(isinstance(tup, tuple) and len(tup) == 2) for tup in longpages) + self.assertTrue(all(isinstance(tup[0], pywikibot.Page) for tup in longpages)) + self.assertTrue(all(isinstance(tup[1], int) for tup in longpages)) + + def test_shortpages(self): + """Test the site.shortpages() method.""" + mysite = self.get_site() + shortpages = list(mysite.shortpages(total=10)) + + # Make sure each object returned by site.shortpages() is + # a tuple of a Page object and an int + self.assertTrue(all(isinstance(tup, tuple) and len(tup) == 2) for tup in shortpages) + self.assertTrue(all(isinstance(tup[0], pywikibot.Page) for tup in shortpages)) + self.assertTrue(all(isinstance(tup[1], int) for tup in shortpages)) + + def test_ancientpages(self): + """Test the site.ancientpages() method.""" + mysite = self.get_site() + ancientpages = list(mysite.ancientpages(total=10)) + + # Make sure each object returned by site.ancientpages() is + # a tuple of a Page object and a Timestamp object + self.assertTrue(all(isinstance(tup, tuple) and len(tup) == 2) for tup in ancientpages) + self.assertTrue(all(isinstance(tup[0], pywikibot.Page) for tup in ancientpages)) + self.assertTrue(all(isinstance(tup[1], pywikibot.Timestamp) for tup in ancientpages)) + + def test_unwatchedpages(self): + """Test the site.unwatchedpages() method.""" + mysite = self.get_site() + try: + unwatchedpages = list(mysite.unwatchedpages(total=10)) + except api.APIError as error: + if error.code == 'gqpspecialpage-cantexecute': + # User must have correct permissions to use Special:UnwatchedPages + raise unittest.SkipTest(error) + raise + + # Make sure each object returned by site.unwatchedpages() is a Page object + self.assertTrue(all(isinstance(p, pywikibot.Page) for p in unwatchedpages)) + def testBlocks(self): """Test the site.blocks() method.""" mysite = self.get_site()
pywikibot-commits@lists.wikimedia.org