Beispiel #1
0
 def test_dry(self):
     """Test dry run of bot."""
     delete.main('-page:Main Page', '-always', '-summary:foo')
     self.assertEqual(self.delete_args,
                      ['[[Main Page]]', 'foo', False, True, True])
     delete.main('-page:FoooOoOooO', '-always', '-summary:foo', '-undelete')
     self.assertEqual(self.undelete_args, ['[[FoooOoOooO]]', 'foo'])
 def test_dry(self):
     """Test dry run of bot."""
     delete.main('-page:Main Page', '-always', '-summary:foo')
     self.assertEqual(self.delete_args, ['[[Main Page]]', 'foo', False,
                                         True, True])
     delete.main('-page:FoooOoOooO', '-always', '-summary:foo', '-undelete')
     self.assertEqual(self.undelete_args, ['[[FoooOoOooO]]', 'foo'])
 def test_undelete_existing(self):
     """Test undeleting an existing page."""
     site = self.get_site()
     p1 = pywikibot.Page(site, 'User:Unicodesnowman/ExistingPage')
     if not p1.exists():
         p1.text = 'pywikibot unit test page'
         p1.save('unit test', botflag=True)
     delete.main('-page:User:Unicodesnowman/ExistingPage', '-always',
                 '-undelete', '-summary=pywikibot unit tests')
 def test_undelete_existing(self):
     """Test undeleting an existing page."""
     site = self.get_site()
     p1 = pywikibot.Page(site, 'User:Unicodesnowman/ExistingPage')
     if not p1.exists():
         p1.text = 'pywikibot unit test page'
         p1.save('unit test', botflag=True)
     delete.main('-page:User:Unicodesnowman/ExistingPage', '-always',
                 '-undelete', '-summary=pywikibot unit tests')
 def test_delete_mark(self):
     """Test marking User:Unicodesnowman/DeleteMark for deletion."""
     site = self.get_site()
     p1 = pywikibot.Page(site, 'User:Unicodesnowman/DeleteMark')
     if not p1.exists():
         p1.text = 'foo'
         p1.save('unit test', botflag=True)
     delete.main('-page:User:Unicodesnowman/DeleteMark', '-always',
                 '-summary=pywikibot unit test. Do NOT actually delete.')
     self.assertEqual(p1.get(force=True), '{{delete|1=pywikibot unit test. '
                      'Do NOT actually delete.}}\nfoo')
     p1.text = 'foo'
     p1.save('unit test', botflag=True)
    def test_delete_mark(self):
        site = self.get_site()
        if site.username(sysop=True):
            raise unittest.SkipTest('can\'t test mark with sysop account')

        p1 = pywikibot.Page(site, 'User:Unicodesnowman/DeleteMark')
        if not p1.exists():
            p1.text = 'foo'
            p1.save('unit test', botflag=True)
        delete.main('-page:User:Unicodesnowman/DeleteMark', '-always',
                    '-summary=pywikibot unit test. Do NOT actually delete.')
        self.assertEqual(p1.get(force=True), '{{delete|1=pywikibot unit test. '
                         'Do NOT actually delete.}}\nfoo')
        p1.text = 'foo'
        p1.save('unit test', botflag=True)
Beispiel #7
0
    def test_delete_mark(self):
        site = self.get_site()
        if site.username(sysop=True):
            raise unittest.SkipTest('can\'t test mark with sysop account')

        p1 = pywikibot.Page(site, 'User:Unicodesnowman/DeleteMark')
        if not p1.exists():
            p1.text = 'foo'
            p1.save('unit test', botflag=True)
        delete.main('-page:User:Unicodesnowman/DeleteMark', '-always',
                    '-summary=pywikibot unit test. Do NOT actually delete.')
        self.assertEqual(
            p1.get(force=True), '{{delete|1=pywikibot unit test. '
            'Do NOT actually delete.}}\nfoo')
        p1.text = 'foo'
        p1.save('unit test', botflag=True)
 def test_delete(self):
     """Test deletionbot on the test wiki."""
     site = self.get_site()
     cat = pywikibot.Category(site, 'Pywikibot Delete Test')
     delete.main('-cat:Pywikibot_Delete_Test', '-always')
     self.assertEmpty(list(cat.members()))
     delete.main('-page:User:Unicodesnowman/DeleteTest1', '-always',
                 '-undelete', '-summary=pywikibot unit tests')
     delete.main('-page:User:Unicodesnowman/DeleteTest2', '-always',
                 '-undelete', '-summary=pywikibot unit tests')
     self.assertLength(list(cat.members()), 2)
 def test_delete(self):
     """Test deletionbot on the test wiki."""
     site = self.get_site()
     cat = pywikibot.Category(site, 'Pywikibot Delete Test')
     delete.main('-cat:Pywikibot_Delete_Test', '-always')
     self.assertEqual(len(list(cat.members())), 0)
     delete.main('-page:User:Unicodesnowman/DeleteTest1', '-always',
                 '-undelete', '-summary=pywikibot unit tests')
     delete.main('-page:User:Unicodesnowman/DeleteTest2', '-always',
                 '-undelete', '-summary=pywikibot unit tests')
     self.assertEqual(len(list(cat.members())), 2)