Sn1per has uploaded a new change for review.
https://gerrit.wikimedia.org/r/185794
Change subject: protect.py unit tests
......................................................................
protect.py unit tests
Test protect/unprotect page on test wiki
Test i18n automatic edit summaries when (un)protecting
Bug: T87155
Change-Id: I22cea8887b1146db39ee5e6bd84cbcddecf2ea4a
---
A tests/protectbot_tests.py
1 file changed, 58 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/94/185794/1
diff --git a/tests/protectbot_tests.py b/tests/protectbot_tests.py
new file mode 100644
index 0000000..4f76d07
--- /dev/null
+++ b/tests/protectbot_tests.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+"""Tests for scripts/protect.py."""
+#
+# (C) Pywikibot team, 2014
+#
+# Distributed under the terms of the MIT license.
+#
+__version__ = '$Id$'
+
+import pywikibot
+import pywikibot.page
+
+from scripts import protect
+
+from tests.aspects import unittest, ScriptMainTestCase
+
+class TestProtectionBot(ScriptMainTestCase):
+
+ """Test ProtectionBot protect/unprotect capabilities."""
+
+ family = 'test'
+ code = 'test'
+
+ sysop = True
+ write = True
+
+ def test_protect(self):
+ """Test ProtectionBot protect/unprotect on the test wiki."""
+ site = self.get_site()
+ protect.main('-page:User:Sn1per/ProtectTest1', '-always',
+ '-unprotect', '-summary=Pywikibot protect.py unit tests')
+ page = pywikibot.Page(site, 'User:Sn1per/ProtectTest1')
+ self.assertEqual(len(list(page.protection())), 0)
+ protect.main('-page:User:Sn1per/ProtectTest1', '-always',
+ '-default', '-summary=Pywikibot protect.py unit tests')
+ page.get(force=True)
+ self.assertEqual(len(list(page.protection())), 2)
+
+ def test_summary(self):
+ """Test automatic (un)protection summary on the test wiki."""
+ site = self.get_site()
+ cat = pywikibot.Category(site, 'Pywikibot Protect Test')
+ protect.main('-cat:Pywikibot Protect Test', '-always',
+ '-unprotect')
+ protect.main('-cat:Pywikibot Protect Test', '-always',
+ '-default')
+ page = pywikibot.Page(site, 'User:Sn1per/ProtectTest2')
+ rev = list(page.revisions())
+ self.assertEqual(rev[1].comment,
+ 'Removed protection from
"[[User:Sn1per/ProtectTest2]]": Bot: Unprotecting all pages from category
Pywikibot Protect Test')
+ self.assertEqual(rev[0].comment,
+ 'Protected "[[User:Sn1per/ProtectTest2]]": Bot:
Protecting all pages from category Pywikibot Protect Test')
+
+if __name__ == '__main__':
+ try:
+ unittest.main()
+ except SystemExit:
+ pass
--
To view, visit https://gerrit.wikimedia.org/r/185794
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I22cea8887b1146db39ee5e6bd84cbcddecf2ea4a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Sn1per <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits