Ejemplo n.º 1
0
 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'])
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
 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')
Ejemplo n.º 6
0
 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')
Ejemplo n.º 7
0
 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')
Ejemplo n.º 8
0
 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())
Ejemplo n.º 9
0
 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()