예제 #1
0
 def test_RepeatingGenerator(self):
     """Test RepeatingGenerator."""
     items = list(
         pagegenerators.RepeatingGenerator(self.site.recentchanges,
                                           key_func=lambda x: x['revid'],
                                           sleep_duration=10,
                                           reverse=True,
                                           namespaces=[0],
                                           total=self.length)
     )
     self.assertEqual(len(items), self.length)
     timestamps = [pywikibot.Timestamp.fromISOformat(item['timestamp'])
                   for item in items]
     self.assertEqual(sorted(timestamps), timestamps)
     self.assertTrue(all(item['ns'] == 0 for item in items))
     self.assertEqual(len(set(item['revid'] for item in items)), self.length)
예제 #2
0
 def test_RepeatingGenerator(self):
     # site.recentchanges() includes external edits (from wikidata),
     # so total=4 is not too high
     items = list(
         pagegenerators.RepeatingGenerator(self.site.recentchanges,
                                           key_func=lambda x: x['revid'],
                                           sleep_duration=10,
                                           reverse=True,
                                           namespaces=[0],
                                           total=4))
     self.assertEqual(len(items), 4)
     timestamps = [
         pywikibot.Timestamp.fromISOformat(item['timestamp'])
         for item in items
     ]
     self.assertEqual(sorted(timestamps), timestamps)
     self.assertTrue(all(item['ns'] == 0 for item in items))
     self.assertEqual(len(set(item['revid'] for item in items)), 4)