def test_dry(self): """Test dry run of bot.""" with empty_sites(): delete.main('-page:Main Page', '-always', '-summary:foo') self.assertEqual(self.delete_args, ['[[Main Page]]', 'foo', False, True, True]) with empty_sites(): delete.main( '-page:FoooOoOooO', '-always', '-summary:foo', '-undelete') self.assertEqual(self.undelete_args, ['[[FoooOoOooO]]', 'foo'])
def tearDown(self): """Bring back the old bot class.""" replace.ReplaceRobot = self._original_bot replace.pywikibot.input = self._original_input replace.pywikibot.Site = self._original_site with empty_sites(): super().tearDown()
def test_invalid_replacements(self): """Test invalid command line replacement configurations.""" # old and new need to be together self.assertFalse(self._run('foo', '-pairsfile:/dev/null', 'bar')) # only old provided with empty_sites(): self.assertFalse(self._run('foo')) # In the end no bots should've been created self.assertFalse(self.bots)
def test_invalid_replacements(self): """Test invalid command line replacement configurations.""" # old and new no longer need to be together but pairsfile must exist self._run('foo', '-pairsfile:/dev/null', 'bar') self.assertIn('Error loading /dev/null:', pywikibot.bot.ui.pop_output()[0]) # only old provided with empty_sites(): self._run('foo') self.assertEqual([ 'Incomplete command line pattern replacement pair.', ], pywikibot.bot.ui.pop_output()) # In the end no bots should've been created self.assertFalse(self.bots)
def test_existing_file(self): """Test uploading a file that already exists.""" with empty_sites(): data_ingestion.main( '-csvdir:tests/data', '-page:User:John_Vandenberg/data_ingestion_test_template')
def test_isbn_to13(self): """Test to13 using the bot and wikibase.""" with empty_sites(): main('-page:' + self.test_page_qid, '-always', '-to13') self.assertTrue(self.setTarget_value, '978-0975229804')
def test_isbn_format(self): """Test format using the bot and wikibase.""" with empty_sites(): main('-page:' + self.test_page_qid, '-always', '-format') self.assertEqual(self.setTarget_value, '0-9752298-0-X')
def test_main(self): """Test main function interwikidata.py.""" # The main function should return False when no generator is defined. with empty_sites(): self.assertFalse(interwikidata.main())
def tearDown(self): """Tear down the test by undoing the bot class patch.""" ReferencesRobot.__init__ = self._original_constructor ReferencesRobot.run = self._original_run with empty_sites(): super().tearDown()