jenkins-bot has submitted this change and it was merged.

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, 66 insertions(+), 0 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/protectbot_tests.py b/tests/protectbot_tests.py
new file mode 100644
index 0000000..df7d56b
--- /dev/null
+++ b/tests/protectbot_tests.py
@@ -0,0 +1,66 @@
+# -*- 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 = pywikibot.Page(site, 'User:Sn1per/ProtectTest1')
+        self.assertEqual(len(list(page.protection())), 2)
+
+    def test_summary(self):
+        """Test automatic (un)protection summary on the test wiki."""
+        site = self.get_site()
+        protect.main('-cat:Pywikibot Protect Test', '-always',
+                     '-default')
+        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 '
+            '([Edit=Allow only administrators] (indefinite) [Move=Allow only '
+            'administrators] (indefinite))')
+
+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: merged
Gerrit-Change-Id: I22cea8887b1146db39ee5e6bd84cbcddecf2ea4a
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Sn1per <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to