def test_strip_cfd_templates_does_nothing_when_no_templates(self): """Test that when there are no CFD templates, the page text is not changed.""" bot = CategoryMoveRobot(oldcat='Old', newcat='New') bot.newcat.text = "Nothing should change.\n\nAnother line." bot._strip_cfd_templates(commit=False) self.assertEqual(bot.newcat.text, "Nothing should change.\n\nAnother line.")
def _runtest_strip_cfd_templates(self, template_start, template_end): """Run a CFD template stripping test with the given CFD start/end templates.""" bot = CategoryMoveRobot(oldcat='Old', newcat='New') bot.newcat.text = '\n'.join( ('Preamble', template_start, 'Random text inside template', 'Even another template: {{cfr-speedy}}', template_end, 'Footer stuff afterwards', '', '[[Category:Should remain]]')) expected = '\n'.join(('Preamble', 'Footer stuff afterwards', '', '[[Category:Should remain]]')) bot._strip_cfd_templates(commit=False) self.assertEqual(bot.newcat.text, expected)
def one_cat(OLDCAT): oldcatObject = pywikibot.Page(site, "Kategorija:{}".format(OLDCAT)) if not oldcatObject.isRedirectPage(): return 0 # NEWCAT = oldcatObject.getRedirectTarget().title(withNamespace=False) #pywikibot.output(NEWCAT) SUMMARY = 'kategorija "{}" → "{}"'.format(OLDCAT.replace('_', ' '), NEWCAT.replace('_', ' ')) q = CategoryMoveRobot(OLDCAT, NEWCAT, batch=True, comment=SUMMARY, inplace=True, delete_oldcat=False) q.run()