Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #4107
Status: Broken
Duration: 2 hours, 22 minutes, and 52 seconds
Commit: bd625de (master)
Author: xqt
Message: Revert "Add all redirects of template "Category redirect" for enwiki, eswiki, ptwiki, trwiki, ukwiki."
Redirected templates aren't necessary because they are retrieved via
family._get_cr_templates from api, see 5c382e9d
This reverts commit 092c9304478df93ab11b6c6b542cffe2be1b3827.
Change-Id: I3bb304362da6f58c440039dd9777003ea8a31567
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/73bb9b12b048...bd625de1…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/241139684?utm_source=…
--
You can configure recipients for build notifications in your .travis.yml file. See https://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/294901 )
Change subject: Implement pywikibot support for adding thanks to normal revisions
......................................................................
Implement pywikibot support for adding thanks to normal revisions
Add methods and tests which enable pywikibot support for thanking
normal revisions.
Bug: T135409
Change-Id: I087f669d7de4ce705c9a6947c82e8b2d51aea09c
---
M pywikibot/page.py
M pywikibot/site.py
A tests/thanks_tests.py
3 files changed, 96 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 4c5d56f..0c8fb44 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -3462,6 +3462,23 @@
item.pageid() > 0
)
+ @property
+ def is_thankable(self):
+ """
+ Determine if the user has thanks notifications enabled.
+
+ NOTE: This doesn't accurately determine if thanks is enabled for user.
+ Privacy of thanks preferences is under discussion, please see
+ https://phabricator.wikimedia.org/T57401#2216861, and
+ https://phabricator.wikimedia.org/T120753#1863894
+
+ @rtype: bool
+ """
+ if self.isAnonymous():
+ return False
+
+ return True
+
class WikibasePage(BasePage):
@@ -5167,6 +5184,17 @@
return Revision.FullHistEntry(self.revid, self.timestamp, self.user,
self.text, self.rollbacktoken)
+ @staticmethod
+ def _thank(revid, site, source='pywikibot'):
+ """Thank a user for this revision.
+
+ @param site: The Site object for this revision.
+ @type site: Site
+ @param source: An optional source to pass to the API.
+ @type source: str
+ """
+ site.thank_revision(revid, source)
+
class FileInfo(DotReadableDict):
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 7c778c9..48a8877 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -6774,6 +6774,25 @@
comparison = data['compare']['*']
return comparison
+ @need_extension('Thanks')
+ def thank_revision(self, revid, source=None):
+ """Corresponding method to the 'action=thank' API action.
+
+ @param revid: Revision ID for the revision to be thanked.
+ @type revid: int
+ @param source: A source for the thanking operation.
+ @type source: str
+ @raise APIError: On thanking oneself or other API errors.
+ @return: The API response.
+ """
+ token = self.tokens['csrf']
+ req = self._simple_request(action='thank', rev=revid, token=token,
+ source=source)
+ data = req.submit()
+ if data['result']['success'] != 1:
+ raise api.APIError('Thanking unsuccessful')
+ return data
+
# Flow API calls
@need_extension('Flow')
def load_board(self, page):
diff --git a/tests/thanks_tests.py b/tests/thanks_tests.py
new file mode 100644
index 0000000..cab6cb3
--- /dev/null
+++ b/tests/thanks_tests.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+"""Tests for thanks-related code."""
+#
+# (C) Pywikibot team, 2016-17
+#
+# Distributed under the terms of the MIT license.
+#
+from __future__ import absolute_import, unicode_literals
+
+from pywikibot.page import Revision, User
+
+from tests.aspects import TestCase
+
+
+class TestThankRevision(TestCase):
+
+ """Test thanks for revisions."""
+
+ family = 'test'
+ code = 'test'
+
+ write = True
+
+ def test_thank_revision(self):
+ """Test thanks for normal revisions.
+
+ NOTE: This test relies on activity in recentchanges, and
+ there must make edits made before reruns of this test.
+ Please see https://phabricator.wikimedia.org/T137836.
+ """
+ found_log = can_thank = False
+ site = self.get_site()
+ data = site.recentchanges(total=50, reverse=True)
+ for i in data:
+ revid = i['revid']
+ username = i['user']
+ user = User(site, username)
+ if user.is_thankable:
+ can_thank = True
+ break
+ if not can_thank:
+ self.skipTest('There is no recent change which can be test thanked.')
+ before_time = site.getcurrenttimestamp()
+ Revision._thank(revid, site, source='pywikibot test')
+ log_entries = site.logevents(logtype='thanks', total=5, start=before_time, page=user)
+ for __ in log_entries:
+ found_log = True
+ break
+ self.assertTrue(found_log)
--
To view, visit https://gerrit.wikimedia.org/r/294901
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I087f669d7de4ce705c9a6947c82e8b2d51aea09c
Gerrit-PatchSet: 13
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Darthbhyrava <hbhyrava(a)gmail.com>
Gerrit-Reviewer: Darthbhyrava <hbhyrava(a)gmail.com>
Gerrit-Reviewer: Happy5214 <happy5214(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm(a)member.fsf.org>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Polybuildr <v.a.ghaisas(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>