Unicornisaurous added a comment.

I wrote a basic test (not yet submitted to Gerrit) for the year page generator:

  class TestYearPageGenerator(DefaultSiteTestCase):
  
      """Test the year page generator"""
  
      def test_basic(self):
          site = self.get_site()
          start = 42
          end = 2026
  
          i = 0
          for page in pagegenerators.YearPageGenerator(start, end, site):
              self.assertIsInstance(page, pywikibot.Page)
              self.assertEqual(date.formatYear(site.lang, start+i), 
page.title(asLink=False));
              i += 1
          self.assertEqual(start+i-1, end)

It checks that each Page instance was generated and that it has the correct 
title, and also that the correct number of pages were generated. I have tested 
it on a few of the mentioned non-Wikipedia sites without any issues, however my 
test does not even issue any API requests (I don't even check  `.exists()`, as 
that takes a while for all of the years. Should I reduce the number of years I 
test and also test weather  `.exists` returns a bool?).

This bug report suggested that it was likely these generators would not work as 
expected, but as I am not very familiar with pywikibot, I have no sense of how 
these might fail, or what else I need to test.

I also wrote a simplistic test (also not submitted to Gerrit) for the day page 
generator:

  class TestDayPageGenerator(DefaultSiteTestCase):
  
      """Test the day page generator"""
  
      def test_basic(self):
          site = self.get_site()
          fd = date.FormatDate(site)
          startMonth = 1
          endMonth = 12
  
          gen = pagegenerators.DayPageGenerator(startMonth, endMonth, site)
  
          expected = []
          for month in range(startMonth, endMonth + 1):
              for day in range(1, date.getNumberOfDaysInMonth(month) + 1):
                  expected.append(fd(month, day))
  
          self.assertPageTitlesEqual(gen, expected)
  
          for page in pagegenerators.DayPageGenerator(startMonth, endMonth, 
site):
              self.assertIsInstance(page, pywikibot.Page)
              exists = page.exists() # this takes a long while
              self.assertIsInstance(exists, bool) # this takes a long while

Any advice is welcome.


TASK DETAIL
  https://phabricator.wikimedia.org/T85313

REPLY HANDLER ACTIONS
  Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign 
<username>.

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Unicornisaurous
Cc: Aklapper, jayvdb, pywikipedia-bugs



_______________________________________________
Pywikipedia-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-bugs

Reply via email to